create a instance of class python getattr code example
Example: python __getattr__ geeksforgeeks
class Foo(object):
def __init__(self):
self.bar = "bar attribute"
def __getattr__(self, attr):
return attr.upper()
foo = Foo()
print(foo.bar) # Output: bar attribute
print(foo.another_no_exist_attribute) # Output: ANOTHER_NO_EXIST_ATTRIBUTE
print(foo.itworks) # Output: ITWORKS