All,
I want simple meta information to be enclosed on an list object, see below code.
>>> a = []
>>> a.foo = 100
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
AttributeError: 'list' object has no attribute 'foo'
>>> setattr(a,"foo",100)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
AttributeError: 'list' object has no attribute 'foo'
>>> dir(a)
...
'__setattr__',
'__setitem__',
...
my quesions are
why I can not use setattr() for variable "a" as the list should have 'setattr' function already?
is there a simple way to attach meta info to list/tuple variable instead of overload 'setattr' or embedded that list into a dict?
thanks!