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.[color=blue][color=green][color=darkred]
>>> o = object()
>>> o.a = 5[/color][/color][/color]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'object' object has no attribute 'a'
But if I do:[color=blue][color=green][color=darkred]
>>> class c(object):
>>> pass
>>> o = c()
>>> o.a = 5[/color][/color][/color]
....then it, of course, works.
So what's wrong with the first example?
--
Stach Tlen: stachobywatelpl , GG: 1811474
Jabber: stach at jabber atman pl
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.[color=blue][color=green][color=darkred]
>>> o = object()
>>> o.a = 5[/color][/color][/color]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'object' object has no attribute 'a'
But if I do:[color=blue][color=green][color=darkred]
>>> class c(object):
>>> pass
>>> o = c()
>>> o.a = 5[/color][/color][/color]
....then it, of course, works.
So what's wrong with the first example?
--
Stach Tlen: stachobywatelpl , GG: 1811474
Jabber: stach at jabber atman pl
Comment