osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

singleton ... again


On Thu, Feb 13, 2014 at 3:24 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> Of course it can happen by accident. It's happened to me, where I've
> accidentally called NoneType() (which raises, rather than returning a new
> instance).

It does in 2.7, yes, but not in 3.4:

>>> type(None)() is None
True

Definitely prefer returning the singleton to raising.

ChrisA