I would like to check whether the Child
class defined classattr
(which might be also defined in its parent class). This is a MWE:
class Base(object):
classattr=1
class Child(Base):
pass
print(hasattr(Child,'classattr'))
which prints True
. The same happens using inspect.getmebers
.
How can I find out in which class was the class attribute defined?