how a class attributes created in python code example
Example: class attributes in python
class MyClass:
# Class attributes are defined outside of constructor
class_attr = 0
def __init__(self, inst):
# Instance attributes are defined in the constructor
self.instance_attr = inst
obj = MyClass(1)
print(obj.class_attr) # outputs 0
print(obj.instance_attr) # outputs 1
print(MyClass.class_attr) # outputs 0
print(MyClass.instance_attr) # raises AttributeError