else in list comp
Erik Max Francis
max at alcyone.com
Wed Jan 29 05:42:05 EST 2003
Alex Martelli wrote:
> IF (a BIG if) this is such a problem that it's worth adding stuff
> to Python, then clearly the added stuff must be general -- namely,
> a ternary (if not an even wider one-of-N) short-circuiting operator.
I agree. If you're really wanting an else clause in the context of a
list comprehension, you really should be thinking instead in terms of
wanting a conditional/tenary operator, rather than some special syntax
specific to list comprehensions only.
As you suggest with your emphasis on _if_, whether you do that is really
independent of the value you attach to a conditional operator being
introduced to Python (I myself am in favor of it).
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ The color is red / Under my shoe
\__/ Neneh Cherry
CatCam / http://www.catcam.com/
What do your pets do all day while you're at work? Find out.
More information about the Python-list
mailing list