NoneType and new instances

Billy Mays 81282ed9a88799d21e77957df2d84bd6514d9af6 at myhashismyemail.com
Thu Jul 28 17:34:22 CEST 2011


On 07/28/2011 11:39 AM, Ethan Furman wrote:
> <class 'NoneType'>
> Traceback (most recent call last):
> File "<stdin>", line 3, in <module>
> TypeError: cannot create 'NoneType' instances
>
> Why is NoneType unable to produce a None instance? I realise that None
> is a singleton, but so are True and False, and bool is able to handle
> returning them:
>
> --> bool(0) is bool(0)
> True
>
> This feels like a violation of 'Special cases aren't special enough to
> break the rules.'
>
> ~Ethan~


Probably for the same reason Ellipsis and NotImplemented also can't be 
instantiated.  What that reason is I don't know.  Related:

http://bugs.python.org/issue6477#msg90641

--
Bill



More information about the Python-list mailing list