PEP 308 vote type (was Re: Update to PEP308: if-then-else expression)

Bengt Richter bokr at oz.net
Wed Feb 12 23:47:13 CET 2003


On Tue, 11 Feb 2003 23:40:13 -0500, "Terry Reedy" <tjreedy at udel.edu> wrote:

>
>"Delaney, Timothy C (Timothy)" <tdelaney at avaya.com> wrote in message
>
>+0 on having a ternary at all (was -0, but found an option I liked);
>
>That is not exactly an option.  The currently-used ternary,
>conditional on the first option being non-null, is "test and opt1 or
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 My latest idea focuses on fixing this instead of inventing a new ternary.

>opt 2".  To me, 100 uses in the standard library makes it
>quasi-officially 'blessed'.  In any case, it is a straightforward
>application of Python's syntax rules.  This is the status quo that a
>no vote is voting for.
>
The idea works by marking the first option so that it will be treated
as True in logical expression context, but without changing its value. E.g.,

    cond and {x} or y
or
    cond and {x} or {y}

for the sake of stylistic symmetry, if desired.

Regards,
Bengt Richter




More information about the Python-list mailing list