On 5/25/07, Greg Ewing <[EMAIL PROTECTED]> wrote:
>
> > 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.
There is already a __bool__ method in 3k. It's the old __nonzero__ method.
>>> 5 .__bool__()
True
>>> 0 .__bool__()
False
>>> class F:
... def __bool__(self): return 5
>>> if F(): print('is')
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __bool__ should return bool, returned int
n
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com