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.

classification
Title: bool.toggle()
Type: enhancement Stage:
Components: Versions: Python 3.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: James.Lu, eric.smith, rhettinger
Priority: normal Keywords:

Created on 2013-07-23 16:07 by James.Lu, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (7)
msg193608 - (view) Author: James Lu (James.Lu) * Date: 2013-07-23 16:07
the bool type should have a toggle() function
msg193609 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2013-07-23 16:10
bool instances are immutable, so all "value.toggle()" could do is the same as "not value". That is, return a new bool with the "toggled" value.
msg193610 - (view) Author: James Lu (James.Lu) * Date: 2013-07-23 16:12
I mean, return a value, some people like this style.

james

On Tue, Jul 23, 2013 at 12:10 PM, Eric V. Smith <report@bugs.python.org>wrote:

>
> Eric V. Smith added the comment:
>
> bool instances are immutable, so all "value.toggle()" could do is the same
> as "not value". That is, return a new bool with the "toggled" value.
>
> ----------
> nosy: +eric.smith
> resolution:  -> invalid
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue18537>
> _______________________________________
>
msg193611 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2013-07-23 16:23
Since it would be the same as "not value", I can't imagine this would be added to the language.
msg193612 - (view) Author: James Lu (James.Lu) * Date: 2013-07-23 16:29
well, filter() could take the function not lambda x:not x

james

On Tue, Jul 23, 2013 at 12:23 PM, Eric V. Smith <report@bugs.python.org>wrote:

>
> Eric V. Smith added the comment:
>
> Since it would be the same as "not value", I can't imagine this would be
> added to the language.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue18537>
> _______________________________________
>
msg193614 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2013-07-23 16:39
If that's your concern, you can use operator.not_.

>>> import operator
>>> filter(operator.not_, [False, True, False, False, True])
[False, False, False]
msg193777 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2013-07-27 06:34
FYI, the itertools module has ifilterfalse() for inverse filtering.
History
Date User Action Args
2022-04-11 14:57:48adminsetgithub: 62737
2013-07-27 06:34:10rhettingersetresolution: not a bug -> rejected

messages: + msg193777
nosy: + rhettinger
2013-07-23 16:39:25eric.smithsetmessages: + msg193614
2013-07-23 16:29:25James.Lusetmessages: + msg193612
2013-07-23 16:23:31eric.smithsetmessages: + msg193611
2013-07-23 16:12:11James.Lusetmessages: + msg193610
2013-07-23 16:10:27eric.smithsetstatus: open -> closed

nosy: + eric.smith
messages: + msg193609

resolution: not a bug
2013-07-23 16:07:38James.Lucreate