class Foo: cls_attr = "Class attribute" def __init__(self, arg1, arg2): self.attr1 = arg1 # Instance attribute self.attr2 = arg2 @classmethod def method_1(cls): # Class method has an access to # class attributes print(cls.cls_attr) return "class method" @staticmethod def method_2(): # print(cls.cls_attr) # NameError: name 'cls' is not defined return "static method" def main(): print(Foo.method_1()) # Class attribute # class method print(Foo.method_2()) # static method f = Foo(1, "a") print("---") # --- print(f.method_1()) # Class attribute # class method print(f.method_2()) # static method if __name__ == '__main__': main()