[Python-ideas] Combining test and assignment
steve at pearwood.info
Sun Jan 22 02:15:42 CET 2012
Jakob Bowyer wrote:
> Say I have a function that is
> def test():
> return sometimes_false
> if test() as x:
> print "Its not false"
> # what happens to x now? is it a NameError or is it None
Neither. It should be syntactic sugar for this:
x = test()
print "Its not false"
So x will always be sometimes_false, whatever that happens to be.
More information about the Python-ideas