Cruxic a écrit : > Is it possible to tack on arbitrary attributes to a python object?
Depends on the object's class. In the common case it's possible but there are a couple cases - mostly builtin immutable types - where it's not. > For example: > > s = 'nice 2 meet you' > s.isFriendly = True > > In the above example Python complains on the second line with: > > AttributeError: 'str' object has no attribute 'isFriendly' > > Is there another way? >>> class MyString(str): pass ... >>> s = MyString("hello") >>> s.is_friendly = True >>> s 'hello' >>> -- http://mail.python.org/mailman/listinfo/python-list