1class Foo(object):
2 def __init__(self):
3 self.bar = "bar attribute"
4
5 def __getattr__(self, attr):
6 return attr.upper()
7
8foo = Foo()
9print(foo.bar) # Output: bar attribute
10print(foo.another_no_exist_attribute) # Output: ANOTHER_NO_EXIST_ATTRIBUTE
11print(foo.itworks) # Output: ITWORKS