class MyClass(object):
a = '12'
b = '34'
def f(self):
return self.a
getattr(MyClass, 'a')
getattr(MyClass, 'c')
getattr(MyClass, 'c', False)
callable(getattr(MyClass, 'a'))
d = {
'a': '123',
'b': '123',
'c': '123',
'f': '123'
}
for key in d.keys():
try:
if getattr(MyClass, key):
if not callable(getattr(MyClass, key)):
print(f'key: {key} is defined variable')
else:
print(f'key: {key} is a member function')
except AttributeError:
print(f'key: {key} is not defined')