[Python-3000] Wither PEP 335 (Overloadable Boolean Operators)?

Greg Ewing greg.ewing at canterbury.ac.nz
Sat May 26 03:41:29 CEST 2007


Jim Jewett wrote:

> It currently says that __not__ can return NotImplemented, which falls
> back to the current semantics.

I'm not sure why I put that there. As you observe, it's not
necessary, since you can always get the default semantics
simply by not defining the method.

An experiment suggests that the existing unary operator
methods don't special-case NotImplemented, so I'll remove
that part.

> It does not yet say what will happen for objects that return something
> else outside of {True, False},

There's nothing to say -- whatever you return is the
result. That's the whole point of making it overloadable.

> Is that OK, because "not not X" should now be spelled "bool(x)", and
> you haven't allowed the overriding of __bool__?

Yes, I would say that 'not not x' should indeed be spelled
bool(x), if that's what you intend it to mean.

Whether __bool__ should be overloadable is outside the scope
of this PEP. But if it is overloadable, I would recommend
that it not be allowed to return anything other than a boolean.

--
Greg


More information about the Python-3000 mailing list