marklists at mceahern.com
Tue Sep 10 05:36:37 CEST 2002
> I've been away from Python for awhile and I'm wondering whether Python got
> less "dynamic" while I was away.
> I thought you could just extend an object's attributes at
> run-time like this:
> >>> p = object()
> >>> p.x = 1
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> AttributeError: 'object' object has no attribute 'x'
object is the base type of new-style classes. Try something like this
>>> class foo:pass
>>> f = foo()
>>> f.x = 1
Or 'class foo(object):pass' works too.
More information about the Python-list