NoneType and new instances

Ben Finney ben+python at benfinney.id.au
Thu Jul 28 19:52:48 EDT 2011


Ethan Furman <ethan at stoneleaf.us> writes:

> Ben Finney wrote:
> > Ethan Furman <ethan at stoneleaf.us> writes:
> >> This feels like a violation of 'Special cases aren't special enough
> >> to break the rules.'
> >
> > In the case of ‘bool’, the rule was broken before being introduced.
>
> I think we disagree on what the rule is.  I see it as "Return an instance
> if you can."

That's not the rule for singletons, though. You've already said what the
rule is:

> Nobody has yet pointed out a good reason on why NoneType,
> NotImplementedType, and ellipsis (to be thorough ;) cannot or should
> not return the single instance that exists

So we agree on what the rule is. The ‘bool’ type breaks that rule, for
the reasons given earlier.

You may want to advocate for a *change* to that rule, or what the rule
*should be*, but that's a different issue.

> when every other built-in will return either a new object, or the
> single object that exists for that value.

What other built-in singleton types are there?

-- 
 \                    “It's all in the mind, you know.” —The Goon Show |
  `\                                                                   |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list