Really stupid question regarding PEP 252 and type/class unification

Alex Martelli aleax at
Fri Aug 31 13:50:19 CEST 2001

"Russell Turpin" <russell_turpin at> wrote in message
news:8a12e538.0108301457.706645ef at
> future data model correctly, it seems to me that "Object"
> should be made a built-in type that follows all the same
> rules as the other built-in types, distinguished primarily
> as being the default base type when no other is listed. In
> particular, I should be able to create instances without
> first sub-classing:
>     spam = Object()       # Create new instance

The time machine strikes again -- all this works fine
already in Python 2.2 alpha 2, except that 'object' is
spelled in lower-case:

Python 2.2a2 (#22, Aug 22 2001, 01:24:03) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> spam = object()

>     spam.eggs = "Yes"

But *this* doesn't work, of course...:

>>> spam.eggs = "Yes"
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'object' object has no attribute 'eggs'

Like those of many other built-in objects, instances of
object have no __dict__ to store arbitrary attributes in:
so, you're limited to using the predefined-slots (of which
I believe object happens to have none:-).  And you're also
underestimating the "ancestorshipness" of object...:

>>> isinstance([],object)
>>> isinstance("peep",object)
>>> isinstance(isinstance,object)
>>> isinstance(None,object)

See...?  Adam and Eve had nothing on this object guy...:-).


More information about the Python-list mailing list