[Python-3000] Wither PEP 335 (Overloadable Boolean Operators)? (original) (raw)
Neal Norwitz nnorwitz at gmail.com
Sat May 26 04:29:19 CEST 2007
- Previous message: [Python-3000] Wither PEP 335 (Overloadable Boolean Operators)?
- Next message: [Python-3000] python/trunk/Lib/test/test_urllib.py (for ftpwrapper)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 5/25/07, Greg Ewing <greg.ewing at canterbury.ac.nz> 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 "", line 1, in TypeError: bool should return bool, returned int
n
- Previous message: [Python-3000] Wither PEP 335 (Overloadable Boolean Operators)?
- Next message: [Python-3000] python/trunk/Lib/test/test_urllib.py (for ftpwrapper)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]