Message139458
| Author |
anacrolix |
| Recipients |
anacrolix |
| Date |
2011年06月30日.05:45:41 |
| SpamBayes Score |
6.694623e-05 |
| Marked as misclassified |
No |
| Message-id |
<1309412742.21.0.0834751390952.issue12447@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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 |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年06月30日 05:45:42 | anacrolix | set | recipients:
+ anacrolix |
| 2011年06月30日 05:45:42 | anacrolix | set | messageid: <1309412742.21.0.0834751390952.issue12447@psf.upfronthosting.co.za> |
| 2011年06月30日 05:45:41 | anacrolix | link | issue12447 messages |
| 2011年06月30日 05:45:41 | anacrolix | create |
|