[Python-Dev] "and" and "or" operators in Py3.0
mwh at python.net
Tue Sep 20 10:11:36 CEST 2005
"Raymond Hettinger" <raymond.hettinger at verizon.net> writes:
> I propose that in Py3.0, the "and" and "or" operators be simplified to
> always return a Boolean value instead of returning the last evaluated
> 2) When going back and forth between languages, it is easy to forget
> that only Python returns something other than a boolean.
As others point out, this isn't true.
> 3) Even when it isn't being used, the possibility of non-boolean return
> value complicates the bytecode and parser. To allow for "and/or", the
> conditional opcodes leave the tested value on the stack.
Huh? I thought this was for chained expressions? Things like 1 < x < 3.
I _like_ the explanation of 'and' and 'or' as they are now. They are
basically control flow constructs -- and have to be to get
short-circuiting to work -- and adding a coercion to bool at the end
seems to add complexity, not reduce it (on some levels, anyway).
> P.S. Simplifying "and" and "or" may create a need to introduce a
> conditional operator but that is a discussion for another day.
... which was in the past, I thought.
The meaning of "brunch" is as yet undefined.
-- Simon Booth, ucam.chat
More information about the Python-Dev