Hi,

I can add new variables to user-defined classes like:

>>> class Test:
...     pass
... 
>>> a=Test()
>>> a.x=100

but it doesn't work if the instances belong to a built-in class such as str or 
list:

>>> a='abc'
>>> a.x=100
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 AttributeError: 'str' object has no attribute 'x'

What makes this difference?

Thanks in advance!
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to