[Python-ideas] Anaphoric if

Andrey Fedorov anfedorov at gmail.com
Fri Apr 23 22:47:34 CEST 2010


I imagine this has been covered before, but somehow my Google-foo is
failing. What are people's opinions about having an anaphoric-if syntax
sugar like:

if foo() as x:
    ... x


meaning

x = foo()
if x:
    ... x


?

I do this a lot, and it seems very un-Pythonically verbose to repeat "x"
(especially when a longer variable name is appropriate).

Cheers,
Andrey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20100423/7007a810/attachment.html>


More information about the Python-ideas mailing list