I understand that in python, whenever you access a class/instance variable, it will call __getattribute__
method to get the result. However I can also use obj.__dict__['x']
directly, and get what I want.
I am a little confused about what is the difference?
Also when I use getattr(obj, name)
, is it calling __getattribute__
or obj.__dict__[name]
internally?
Thanks in advance.