In the function __getattr__(), if a referred variable is not found then it gives an error. How can I check to see if a variable or method exists as part of an objec
__getattr__()
You can try using 'inspect' module:
import inspect def is_method(obj, name): return hasattr(obj, name) and inspect.ismethod(getattr(obj, name)) is_method(dyn, 'mymethod')