[Python-bugs-list] [ python-Bugs-820397 ] __nonzero__() returns 1/0
SourceForge.net
noreply at sourceforge.net
Sat Oct 11 15:13:07 EDT 2003
Bugs item #820397, was opened at 2003-10-08 21:34
Message generated for change (Comment added) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=820397&group_id=5470
Category: None
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: George Yoshida (quiver)
Assigned to: Nobody/Anonymous (nobody)
Summary: __nonzero__() returns 1/0
Initial Comment:
This is similar to Patch [820195].
http://www.python.org/sf/820195
number.__nonzero__() returns 1/0,
while number != 0 returns True/False.
>>> n = 1
>>> n.__nonzero__()
1
>>> n != 0
True
>>> n = 0
>>> n.__nonzero__()
0
>>> n != 0
False
>>> c = 1+1j
>>> c.__nonzero__()
1
>>> c != 0
True
>>> c = 0j
>>> c.__nonzero__()
0
>>> c != 0
False
----------------------------------------------------------------------
>Comment By: Raymond Hettinger (rhettinger)
Date: 2003-10-11 14:13
Message:
Logged In: YES
user_id=80475
Fixed.
See: Objects/typeobject.c 2.247
Thanks for the bug report.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=820397&group_id=5470
More information about the Python-bugs-list
mailing list