[Python-Dev] the not operator (and the __not__ special method)

Greg Ewing greg@cosc.canterbury.ac.nz
Fri, 04 Oct 2002 11:17:10 +1200 (NZST)


Marcelo Matus <mmatus@dinha.acms.arizona.edu>:

> I guess it will be also good to have the special methods for the
> logical operations 'and', 'or' and 'not', (something like __land__,
> __lor__ and __lnot__ to distinguish them from the bitwise versions
> __and__ and __or__).

This is not easy, because the 'and' and 'or' operators
have to be capable of short-circuiting -- which is the
reason they don't already have __xxx__ methods.

But I have some ideas on how it could be done, which I
hope to get around to trying out one day.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+