[Python-Dev] "and" and "or" operators in Py3.0

Brett Cannon bcannon at gmail.com
Wed Sep 21 20:55:41 CEST 2005

On 9/21/05, Michael Hudson <mwh at python.net> wrote:
> Brett Cannon <bcannon at gmail.com> writes:
> > On 9/20/05, Michael Hudson <mwh at python.net> wrote:
> > [SNIP]
> >> 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).
> >>
> >
> > If you change the definition of 'and' and 'or' to be boolean
> > comparison operators (as Raymond is proposing) and not as control flow
> > constructs then is it really that complicated?
> If you eliminate the short circuiting behaviour of 'or' and 'and' the
> mobs will be after you with torches and pitchforks (and I'll be with
> them).

I am not suggesting that at all.  I would put myself on a pike first
before the mob got there.  =)

> > I think it would actually simplify things very slightly since you
> > just say a boolean is returned instead of the last executed
> > expression by the operator.
> You might as well have 'and' be a builtin, then -- or do I misread
> you?

I think you might be misreading me, but since Guido seems to have made
the decision that 'and' and 'or' are not changing there is no need to
try to clarify.

> >> > 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.
> >
> > It was, but changing 'and' and 'or' does tweak the usefulness of a
> > conditional operator.
> Another reason why it's a bad idea :) <wink>



More information about the Python-Dev mailing list