tjreedy at udel.edu
Fri Mar 5 17:57:13 CET 2010
On 3/4/2010 10:32 PM, Steven D'Aprano wrote:
> Python does have it's own singletons, like None, True and False.
True and False are not singletons.
> For some reason, they behave quite differently:
Because they are quite different.
> NoneType fails if you try to instantiate it again,
Because trying 'type(None)()' was probably judged to be more likely to
be a bug than something useful.
> while bool returns the appropriate existing singleton: [sic]
Branching on boolean values (which are no more singletons than 0, 1,
...) is basic to computing.
> I wonder why NoneType doesn't just return None?
What would you have NoneType(x) do? Or the special case NoneType(None)?
The issue has come up as to whether object(x) should ignore or raise.
In 3.x, it raises.
TypeError: object.__new__() takes no parameters
but I believe this is changed from at least some 2.x versions that
ignored (apparently by 'accident').
Terry Jan Reedy
More information about the Python-list