if statement, with function inside it: if (t = Test()) == True:
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Fri Apr 24 06:11:22 EDT 2009
On Fri, 24 Apr 2009 03:00:26 -0700, GC-Martijn wrote:
> Hello,
>
> I'm trying to do a if statement with a function inside it. I want to use
> that variable inside that if loop , without defining it.
>
> def Test():
> return 'Vla'
>
> I searching something like this:
>
> if (t = Test()) == 'Vla':
> print t # Vla
>
> or
>
> if (t = Test()):
> print t # Vla
Fortunately, there is no way of doing that with Python. This is one
source of hard-to-debug bugs that Python doesn't have.
> ------------------------------------------ The long way
> t = Test()
> if (t == 'Vla':
> print t # must contain Vla
What's wrong with that?
--
Steven
More information about the Python-list
mailing list