What's going on here?

Scott David Daniels scott.daniels at acm.org
Wed Nov 22 15:47:54 CET 2006


Dale Strickland-Clark wrote:
> Python 2.4.2 (#1, Oct 13 2006, 17:11:24)
>>>> a = object()
>>>> a.spam = 1
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> AttributeError: 'object' object has no attribute 'spam'
>>>> class B(object): pass
>>>> a = B()
>>>> a.spam = 1
>>>>
> 
> What is subclassing adding to the class here? Why can't I assign to
> attributes of an instance of object?

object itself doesn't have a __dict__ slot, so that very small objects
(such as points) can be built without that overhead.

--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list