Instances of class object not modifiable?

Krzysztof Stachlewski stach at fr.pl
Mon Jan 24 15:40:33 EST 2005


I tried to run the following piece of code:

Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> o = object()
>>> o.a = 5
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'object' object has no attribute 'a'

But if I do:
>>> class c(object):
>>>   pass
>>> o = c()
>>> o.a = 5

...then it, of course, works.
So what's wrong with the first example?

-- 
Stach  Tlen: stachobywatelpl, GG: 1811474
       Jabber: stach at jabber atman pl



More information about the Python-list mailing list