PEP 308: "then" "else" for deprecating "and" "or" side effects

A. Lloyd Flanagan alloydflanagan at attbi.com
Wed Feb 26 17:38:39 EST 2003


"Sean Ross" <sross at connectmail.carleton.ca> wrote in message news:<log3a.33806$Ww1.902882 at news20.bellglobal.com>...
> And, while we're here, doesn't that sound nice?
> 
>     wear = "jacket" when outside.iscold() else None
> 

I'm convinced.
+1 to 'x when C else y'

As for the utility of this operator, I find myself all the time doing:
if C:
   b = x
else:
   b = y

and thinking, "gee, I could use a ternary operator here."




More information about the Python-list mailing list