On 2012-08-16 14:47, Hans Mulder wrote:
On 8/08/12 04:14:01, Steven D'Aprano 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
Why is that?
Because None is a singleton. It is the only instance of its class. This
is very useful because it allows you to write conditions like this:
if obj is None:
do_something()
--
http://mail.python.org/mailman/listinfo/python-list