singleton ... again

Chris Angelico rosuav at gmail.com
Thu Feb 13 05:33:11 CET 2014


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



More information about the Python-list mailing list