Looking for a good introduction to object oriented programming with Python

Chris Angelico rosuav at gmail.com
Tue Aug 7 22:24:02 EDT 2012


On Wed, Aug 8, 2012 at 12:14 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> NoneType raises an error if you try to create a second instance. bool
> just returns one of the two singletons (doubletons?) again.
>
> py> type(None)()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: cannot create 'NoneType' instances
> py> type(False)() is False
> True

This is necessitated by the use of bool(x) as a means of boolifying
("casting to bool", if you like) x. I wouldn't want that to change,
and since type(False) is bool, what you see is bound to occur.

ChrisA



More information about the Python-list mailing list