overloading logical not, and, or
Kragen Sitaker
kragen at pobox.com
Mon Jan 28 22:08:22 EST 2002
"Terry Reedy" <tjreedy at home.com> writes:
> '+', etc, needs to be overloadable with __add__ since it is not
> otherwise for class instances. The logical operators are defined for
> everything (via their truth values) and so overloading is not needed,
> nor, very obviously, even sensible (unless one wanted another means to
> horribly obfuscate code). In the expression 'a and b', 'and' operates
> on truth-value(a) rather than on a itself.
I can think of a couple of cases where overloading and, or, etc.,
might be useful:
- Numeric arrays of booleans
- blitz-style code generation
That said, I prefer Python as it is --- with no overloading for
control flow operators like and and or.
More information about the Python-list
mailing list