[Python-Dev] PEP 308: "then" "else" for deprecating "and" "or" side effects

Christian Tismer tismer at tismer.com
Fri Feb 14 06:16:33 EST 2003


M.-A. Lemburg wrote:
> Christian Tismer wrote:
> 
>> Dear community,
>>
>> there has been some favor of my silly/simple a then b else c proposal.
>>
>> Please let me elaborate a little on this, with respect
>> to the existing "and" and "or operators.
>>
>> "and" and "or" are two-headed beasts:
>> At first glance, they pretend to be logical operators.
>> At second inspection, they do this logic by promoting
>> one of their operands.
>>
>> This is not obviously bad, and it is consistant with the logic.
>>
>> Due to the presence of a real boolean type, we
>> should ask ourselves if "and" and "or" shouldn't be
>> deprecated in their current meaning, towards being
>> "boolean only"?
> 
> 
> You are forgetting a detail here: "and" as well as "or"
> are not implemented as operators. "&" and "|" are the
> boolean operators and these do return boolean values.

Na, aber!
You are confusing bitwise orerations which booleans.

 >>> 2 & 1
0
 >>>

"""
5.10 Boolean operations


Boolean operations have the lowest priority of all Python operations:

expression:     or_test | lambda_form
or_test:        and_test | or_test "or" and_test
and_test:       not_test | and_test "and" not_test
not_test:       comparison | "not" not_test
lambda_form:	"lambda" [parameter_list]: expression
"""

...

> Constructs misusing "and" and "or" for the sake of
> inlining if-then-else should be reserved for those
> who know what they're doing (and can live with the
> consequences).

Hey, did you realize what my message is about?
I am talking of a better alternative, not
"and" and "or".

ciao - chris
-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  pager +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/






More information about the Python-list mailing list