PEP-308 a "simplicity-first" alternative

Terry Reedy tjreedy at udel.edu
Fri Feb 14 19:54:31 EST 2003


>"Chermside, Michael" <mchermside at ingdirect.com> wrote in message
news:mailman.1045156244.25228.python-list at python.org...

>Bengt Richter writes:
>> If you understand
>>     x and y or b

>Yes, but what if you don't?
>
>While the idiom might WORK, it's by no means READABLE
>(except to people who are already familiar with the
>idiom). Imagine showing it to a non-programmer, or a
>beginning programmer, or even to a programmer with
>years of experience but who had never seen this particular
>idiom!

I think the problem is not so much the compound as Python's
idiosyncratic definitions of 'and' and 'or' themselves, as useful as
they occasionally are.

>One of the reasons why I WANT a conditional operator
>is so I will stop encountering clever "tricks" like
>and-or in place of readable code.

There is also an or-and version, (not a or b) and c, with a different
failure case 8-0.  (See (PEP-308) Python's Conditional Selection
Operators, which I just posted this evening.)  While I am personally
comforatable with using them, I understand that other are not and that
they are cryptic to anyone who has not read the and/or definitions at
least three times.  So I am willing to vote for and switch to
something else that is not substantially uglier.

Terry J. Reedy







More information about the Python-list mailing list