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

Bengt Richter bokr at oz.net
Tue Feb 11 02:10:17 EST 2003


On Mon, 10 Feb 2003 11:09:53 -0800, "James J. Besemer" <jb at cascade-sys.com> wrote:

>
>
>Erik Max Francis wrote:
>> Evan wrote:
>> 
>> 
>>>t = (if "spam" not in s: "customer"
>>>      elif "eggs" in s: "vikings"
>>>      else: "waitress")

Of the wordy formats, that is probably my favorite, but I prefer no keywords:

   t = ( "spam" not in s  -> "customer"
       >< "eggs" in s     -> "vikings"
                          -> "waitress") # could be spelled  >< True -> "waitress"

or as a one-liner:

   t = "spam" not in s -> "customer" >< "eggs" in s -> "vikings" -> "waitress"

Regards,
Bengt Richter




More information about the Python-list mailing list