Is 'everything' a refrence or isn't it?

Fredrik Lundh fredrik at
Sun Jan 15 12:14:16 CET 2006

Steven D'Aprano wrote:

> I'm sick of arguing about object, let's use a different example:
> >>> id(None)
> 135289128
> >>> type(None)
> <type 'NoneType'>
> What's the value of None? Would you say "it has no value" or "it's value
> is None" or something else?

it has no value (or if you prefer, the set of values is empty).

(unless you're talking about None-the-not-quite-but-almost-keyword, which
always evaluates to the same None object, unless you hack the __builtin__

the None object has an identity and a type.

> None is a singleton, so it is meaningless to ask about two instances of
> NoneType. How about this?
> >>> class Empty:
> ...     pass
> ...
> >>> id(Empty())
> -151107636
> >>> type(Empty())
> <type 'instance'>
> Do two instances of Empty have the same value, or is the question
> meaningless?

Things are a bit mixed up wrt. old-style classes (because they're implemented
in terms of true objects), but if you make that

    >>> class Empty(object):
    ...     __slots__ = []

it should be clear that instances of this class have no value (or if you prefer,
the set of values is empty for all instances), and cannot have one either.

all Empty objects have an identity and a type, though.


More information about the Python-list mailing list