comprehensions was Re: Switch statements again

Erik Max Francis max at
Mon Jan 20 03:24:23 CET 2003

Tim Peters wrote:

> I hope to God nobody is doing that in real life, but then I never
> expected anyone to do
>     (f() and [g()] or [h()])[0]
> in real life either <0.5 wink>.

Well, I hope that in "real life" people aren't really doing this
commonly.  The point of wanting a conditional operator (which I would
gladly welcome in Python, by the way) is readability; this utterly
destroys that.  `p and x or y' (when x is known not to be false) is
barely tolerable, but even that is seriously pushing it.

People don't really commonly use the (p and [x] or [y])[0] trick, do

 Erik Max Francis / max at /
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Yes I'm / Learning from falling down / Heavily
\__/ Lamya
    Fauxident /
 A "faux" ident daemon in Python.

More information about the Python-list mailing list