PEP 308: Erik's alternatives list

John Roth johnroth at ameritech.net
Wed Feb 19 07:55:22 EST 2003


"Erik Max Francis" <max at alcyone.com> wrote in message
news:3E52F313.4B917E50 at alcyone.com...
>
> Here is the list:
>
> I.  Proposals mentioned in the PEP at some point
>
> 1.  x if C else y
> 2.  if C then x else y
> 3.  if C: x else: y
> 4.  C ? x : y
> 5.  C ? x ! y
> 6.  cond(C, x, y)
(*)
> 7.  C ?? x || y
> 8.  C then x else y

Proposal 3 above requires parenthesis around it. They are
not optional. Since 3 does, then I presume that 2 does also.

>
> II.  Proposals which were "seconded"
>
> 1.  x when C else y
> 2.  C ? x else y
> 3.  C -> x else y
> 4.  C -> (x, y)
> 5.  [x if C else y]
> 6.  ifelse C: x else y
(**)
> 7.  <if C then x else y>
> 8.  C and x else y
>
> III.  Proposals but were not "seconded"
>
> 1.  x @ C or else y
> 2.  C if? x else y
> 3.  y or x if C
> 4.  |x if C else y|
> 5.  when C then x otherwise y
> 6.  C ? (x, y)
> 7.  C -> x -> y
> 8.  C then: x else: y
> 9.  C ? x, y
> 10. (? C: x, y ?)
>
> Footnotes:
>
> * This `cond' is a special form, not simply a builtin function, which
> lazily evaluates its last two arguments (depending on the value of the
> first, which _is_ evaluated).  There were also variations on the name
of
> the special form itself.
>
> ** Several alternative names for the starting keyword `ifelse',
> including `select', `when', and `case'.

Many of these forms have had "elif" versions also suggested. I
don't have a list, but I think it applies to just about all of the
ones that use word symbols, and mostly not to the ones
that use special characters.

Great job!

John Roth

>
> --
>  Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
>  __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
> /  \ Many situations can be clarified by the passing of time.
> \__/ Theodore Isaac Rubin
>     CSBuddy / http://www.alcyone.com/pyos/csbuddy/
>  A Counter-Strike server log file monitor in Python.






More information about the Python-list mailing list