This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年06月30日 05:45 by anacrolix, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg139458 - (view) | Author: Matt Joiner (anacrolix) | Date: 2011年06月30日 05:45 | |
Given there is no ! operator in Python, I next tried ~ (despite that I'm after a logical not). This came as a surprise: >>> bool(~True) True >>> bool(~False) True >>> bool(~~False) False >>> ~True, ~~True, ~False, ~~False (-2, 1, -1, 0) Is there any consideration to "fixing" this? Is int(True) 1 due to C? Why is it preferred over -1? It seems more appropriate to me that True have: def __invert__(self): return False def __int__(self): return 1 # or even -1 This also "fixes" this case too: >>> -True -1 |
|||
| msg139459 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2011年06月30日 05:51 | |
Did you try the "not" operator? http://docs.python.org/reference/expressions.html#boolean-operations >>> not True False >>> not False True |
|||
| msg139460 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2011年06月30日 06:11 | |
This is deliberate, and will not be changed (at least not until Python 4, and likely not even then). Please ask on a Python forum about history and motivation of the boolean type in Python if you want to know more. |
|||
| msg349538 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2019年08月13日 10:23 | |
bpo-37831 has been marked as a duplicate of this issue. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:19 | admin | set | github: 56656 |
| 2019年08月13日 10:23:05 | vstinner | set | nosy:
+ vstinner messages: + msg349538 |
| 2019年08月12日 15:28:50 | josh.r | link | issue37831 superseder |
| 2011年06月30日 06:11:08 | loewis | set | status: pending -> closed nosy: + loewis messages: + msg139460 |
| 2011年06月30日 05:51:45 | amaury.forgeotdarc | set | status: open -> pending nosy: + amaury.forgeotdarc messages: + msg139459 resolution: not a bug |
| 2011年06月30日 05:45:41 | anacrolix | create | |