If I have a custom class A and add a function func to a, that works:
>>> class A: pass
...
>>> a = A()
>>> a.func = lambda: None
However, if I try the same for b which is an instance of list, I get the following error:
>>> b = list()
>>> b.func = lambda: None
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute 'func'
This is just an example. It's not always list. Sometimes I just want to add one attribute or a function without having to create a completely new class. (Creating a class and instantiating a single object from that class.) Is that not possible for those certain built-in classes? How do I know which ones and why?