-
-
Notifications
You must be signed in to change notification settings - Fork 29.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
~(True) and ~(False) gives incorrect result #89531
Comments
~(True) returns -2 |
What were you expecting? I think those are correct. See:
>>> ~1
-2
>>> ~0
-1 |
True is a boolean so ~True should return False according to me. |
That's be a BC break for no reason: if you want to invert a boolean you can just
For historical reasons, in Python it is: >>> bool.mro()
[<class 'bool'>, <class 'int'>, <class 'object'>]
>>> True == 1
True
>>> False == 0
True So when you call ~True, you're calling |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: