[ python-Bugs-1695688 ] Unexpected feature vs. integer and True values
SourceForge.net
noreply at sourceforge.net
Fri Apr 6 22:56:53 CEST 2007
Bugs item #1695688, was opened at 2007-04-06 15:28
Message generated for change (Comment added) made by gbrandl
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1695688&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: None
Status: Closed
Resolution: Invalid
Priority: 5
Private: No
Submitted By: dev at bacademy (bacademy)
Assigned to: Nobody/Anonymous (nobody)
Summary: Unexpected feature vs. integer and True values
Initial Comment:
Integer 1 interpreted as True.
I didn't expect the following:
Python 2.5 (r25:51908, Apr 4 2007, 10:19:35)
[GCC 4.1.1 20060724 (prerelease) (4.1.1-3mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> v = 2
>>> 0.0 if v == True else float(v)
2.0
>>> v = 1
>>> 0.0 if v == True else float(v)
0.0
I know how to fix this, by writing
0.0 if v is True else float(v)
but to casual observer it is not obvious...
----------------------------------------------------------------------
>Comment By: Georg Brandl (gbrandl)
Date: 2007-04-06 20:56
Message:
Logged In: YES
user_id=849994
Originator: NO
It may be, but it is not a bug (bool inherits from int) and documented (I
think...).
----------------------------------------------------------------------
Comment By: Georg Brandl (gbrandl)
Date: 2007-04-06 18:01
Message:
Logged In: YES
user_id=849994
Originator: NO
It may be, but it is not a bug (bool inherits from int) and documented (I
think...).
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1695688&group_id=5470
More information about the Python-bugs-list
mailing list