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

M.-A. Lemburg mal at lemburg.com
Fri Feb 14 06:41:21 EST 2003


Christian Tismer wrote:
> 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.

Sorry, I meant "&&" and "||".

> """
> 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".

Sure. I was argueing against adding more inlining
tricks.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Software directly from the Source  (#1, Feb 14 2003)
 >>> Python/Zope Products & Consulting ...         http://www.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
Python UK 2003, Oxford:                                     46 days left
EuroPython 2003, Charleroi, Belgium:                       130 days left






More information about the Python-list mailing list