[Python-ideas] Anaphoric if
Raymond Hettinger
raymond.hettinger at gmail.com
Sat Apr 24 02:26:45 CEST 2010
On Apr 23, 2010, at 1:47 PM, Andrey Fedorov wrote:
> 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).
Yes, this has come up before.
FWIW, I'm +1 on the idea,
especially if it can be also applied to while-loops.
It looks very readable
We do have a language moratorium in effect,
so your odds of success are slim.
Raymond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20100423/1e81baa3/attachment.html>
More information about the Python-ideas
mailing list