-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-82012: Deprecate bitwise inversion (~) of bool #103487
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
Changes from 1 commit
1f0351a
3632ba5
2cbfe2d
e5ec711
2db5864
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -808,19 +808,26 @@ Boolean Type - :class:`bool` | |
============================ | ||
|
||
Booleans represent truth values. The :class:`bool` type has exactly two | ||
constant instances ``True`` and ``False``. | ||
constant instances: ``True`` and ``False``. | ||
|
||
Other types can be cast to bool explicitly using the function :func:`bool`. | ||
Additionally, they are implicitly interpreted as bool in some contexts - see | ||
:ref:`truth`. | ||
.. index:: | ||
single: False | ||
single: True | ||
pair: Boolean; values | ||
|
||
The built-in function :func:`bool` converts any value to a boolean, if the | ||
value can be interpreted as a truth value (see section :ref:`truth` above). | ||
|
||
For logical operations, use the :ref:`boolean operators <boolean>` ``and``, | ||
``or`` and ``not``. | ||
When applying the bitwise operators ``&``, ``|``, ``^`` to two booleans, they | ||
return a bool equivalent to the logical operations "and", "or", "xor". Still, | ||
for ``&`` and ``|``, the logical operators ``and`` and ``or`` are preferred. | ||
The use of the bitwise inversion operator ``~`` is deprecated and will raise | ||
an error in Python 3.14. | ||
|
||
.. deprecated:: 3.12 | ||
|
||
The use of the bitwise inversion operator ``~`` is deprecated and will | ||
raise an error in Python 3.14. | ||
|
||
8000 | :class:`bool` is a subclass of :class:`int` (see :ref:`typesnumeric`). In | |
many numeric contexts, bools behave like the integers 0 and 1, respectively. | ||
|
@@ -5419,20 +5426,6 @@ information. There is exactly one ``NotImplemented`` object. | |
It is written as ``NotImplemented``. | ||
|
||
|
||
.. _bltin-boolean-values: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello. The removal of this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you open a PR, I can backport it to the 3.12 branch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. Please see #110371 . Thank you for your consideration! |
||
|
||
Boolean Values | ||
-------------- | ||
|
||
Boolean values are the two constant objects ``False`` and ``True``. See | ||
:ref:`typebool` for more info. | ||
|
||
.. index:: | ||
single: False | ||
single: True | ||
pair: Boolean; values | ||
|
||
|
||
.. _typesinternal: | ||
|
||
Internal Objects | ||
|
Uh oh!
There was an error while loading. Please reload this page.