[New-bugs-announce] [issue6428] TypeError: __bool__ should return bool or int, returned int
SilentGhost
report at bugs.python.org
Mon Jul 6 16:45:34 CEST 2009
New submission from SilentGhost <michael.mischurow+bpo at gmail.com>:
According to docs
(http://docs.python.org/3.1/reference/datamodel.html#object.__bool__)
__bool__ can return 1 or 0 instead of True or False.
However, when I ran the following code:
Python 3.1 (r31:73574, Jun 26 2009, 20:21:35) [MSC v.1500 32 bit
(Intel)] on win32
>>> class Spam():
def __bool__(self):
return 1
>>> if Spam():
print('ham')
I got the following error:
Traceback (most recent call last):
File "<pyshell#72>", line 1, in <module>
if Spam():
TypeError: __bool__ should return bool or int, returned int
So, do I misunderstand the docs or is it an error in them?
----------
assignee: georg.brandl
components: Documentation, Interpreter Core
messages: 90181
nosy: SilentGhost, georg.brandl
severity: normal
status: open
title: TypeError: __bool__ should return bool or int, returned int
type: behavior
versions: Python 3.1
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6428>
_______________________________________
More information about the New-bugs-announce
mailing list