Issue 1695688: Unexpected feature vs. integer and True values (original) (raw)
Issue1695688
Created on 2007-04-06 15:28 by bacademy, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg31712 - (view) | Author: dev@bacademy (bacademy) | Date: 2007-04-06 15:28 |
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... | ||
msg31713 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2007-04-06 18:01 |
It may be, but it is not a bug (bool inherits from int) and documented (I think...). | ||
msg31714 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2007-04-06 20:56 |
It may be, but it is not a bug (bool inherits from int) and documented (I think...). |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:23 | admin | set | github: 44810 |
2007-04-06 15:28:00 | bacademy | create |