[Python-ideas] True and False are singletons
Richard Damon
Richard at Damon-Family.org
Mon Mar 18 08:19:09 EDT 2019
On 3/18/19 7:27 AM, Greg Ewing wrote:
> Juancarlo Añez wrote:
>
>> if settings[MY_KEY] is True:
>> ...
>
> If I saw code like this, it would take a really good argument to
> convince me that it shouldn't be just
>
> if settings[MY_KEY]:
> ...
>
That means something VERY different. The first asks if the item is
specifically the True value, while the second just asks if the value is
Truthy, it wold be satisfied also for values like 1.
--
Richard Damon
More information about the Python-ideas
mailing list