python: bug or feature?

Bernhard Herzog herzog at online.de
Fri Aug 11 12:29:32 EDT 2000


Keith Murphy <kpmurphy at my-deja.com> writes:

> why not use &&, ||, etc for boolean and &, |, etc for bitwise?

A better question to ask IMO is why does Python use keywords for the
logical operators but special characters for the bitwise operators? This
may just be a different phrasing of your question.

I think one reason might have been that "and" and "or" influence the
control flow (the second operand is only evaluated if necessary to
determine the result) and that they can't be overloaded (if they could
be overloaded, the second operand would always have to be evaluated)

The other keyword operators (is, is not, in, not in) can't be overloaded
either, although that's going to change for in, IIRC.

I don't think introducing && and || for the logical operators would be a
good idea for Python. OTOH, keywords for the bitwise operations would be
OK, IMO, but that's something for Python 3K.

-- 
Bernhard Herzog   | Sketch, a drawing program for Unix
herzog at online.de  | http://sketch.sourceforge.net/



More information about the Python-list mailing list