homepage

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.

Author tomerv
Recipients tomerv
Date 2019年08月12日.10:48:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1565606932.6.0.360898799273.issue37831@roundup.psfhosted.org>
In-reply-to
Content
Bitwise operators have inconsistent behavior when acting on bool values: (Python 3.7.4)
# "&" works like "and"
>>> True & True
True
>>> True & False
False
>>> False & False
False
# "|" works like "or"
>>> True | True
True
>>> True | False
True
>>> False | False
False
# "~" does not work like "not"!
>>> ~True
-2
>>> ~False
-1
The result of this is the a user might start working with "&" and "|" on bool values (for whatever reason) and it will work as expected. But then, when adding "~" to the mix, things start to break.
The proposal is to make "~" act like "not" on bool values, i.e. ~True will be False; ~False will be True.
I'm not sure if this has any negative impact on existing code. I don't expect any, but you can never know. If there is no objection to this change, I can even try to implement it myself an submit a patch.
History
Date User Action Args
2019年08月12日 10:48:52tomervsetrecipients: + tomerv
2019年08月12日 10:48:52tomervsetmessageid: <1565606932.6.0.360898799273.issue37831@roundup.psfhosted.org>
2019年08月12日 10:48:52tomervlinkissue37831 messages
2019年08月12日 10:48:52tomervcreate

AltStyle によって変換されたページ (->オリジナル) /