How is `getattr` related to `object.__getattribute__` and to `object.__getattr__`?

Viewed 4007

From https://docs.python.org/3.6/library/functions.html#getattr

getattr(object, name[, default])

Return the value of the named attribute of object. name must be a string. If the string is the name of one of the object’s attributes, the result is the value of that attribute. For example, getattr(x, 'foobar') is equivalent to x.foobar. If the named attribute does not exist, default is returned if provided, otherwise AttributeError is raised.

How is getattr related to object.__getattribute__ and to object.__getattr__?

Does getattr call object.__getattribute__ or object.__getattr__? I would guess the former?

2 Answers
Related