A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-February/071361.html below:

[Python-Dev] bool conversion wart?

[Python-Dev] bool conversion wart? [Python-Dev] bool conversion wart?Georg Brandl g.brandl at gmx.net
Sat Feb 24 19:42:41 CET 2007
Guido van Rossum schrieb:
> Can anyone who is in favor of changing this please come up with a spec
> for the new bool() signature? What would you do for the most common
> use case of bool(), which is converting an arbitrary value to its
> Boolean equivalent without using an if test or the "not not x" hack?

I think this subthread doesn't propose to change bool(), but only to
stop inheriting bool from int, while giving bools an __index__ method
that returns 0 or 1 to still allow them being used as list indices.

The obvious consequence would be that arithmetic wouldn't work any
longer with bools involved.

Also, mapping access or set membership wouldn't work like now,

 >>> d = {1: 2}
 >>> d[True]
2
 >>> True in set([1])
True

but that would only be logical.

Georg

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4