For review: PEP 308 - If-then-else expression

Erik Max Francis max at alcyone.com
Sun Feb 9 21:02:44 EST 2003


Sean Ross wrote:

> I like this syntax. I agree with the minus point, although there "sort
> of"
> is an implicit list, the list [whentrue, whenfalse]
> which you are "sort of" filtering based on 'condition', although the
> filtering does not return a list, rather an evaluated expression. I do
> think
> it can be confused with list comprehensions. But, without the 'for' ,
> and
> with the inclusion of 'else', they do have a somewhat different
> appearance.

The use of brackets just seems wrong to me (suggesting a list where
there is none).  If the [x if C else y] syntax were truly made a special
case of list comprehensions (although how I can't see), then I could
envision it, but it seems to me that if you're going to require
offsetting punctuation, parentheses are the right one.

I don't think they need be required, but I can't see brackets or curly
braces (suggesting a list and a dictionary, respectively, which is not
there) fitting the bill.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Light ... more light!
\__/ (the last words of Goethe)
    Bosskey.net / http://www.bosskey.net/
 A personal guide to online multiplayer first person shooters.




More information about the Python-list mailing list