class and instance variable in python code example
Example 1: instance variable in python
class Car: wheels = 4 # <- Class variable def __init__(self, name): self.name = name # <- Instance variable
Example 2: call instance class python
# define class
class example:
# define __call__ function
def __call__(self):
print("It worked!")
# create instance
g = example()
# when attempting to call instance of class it will call the __class method
g()
# prints It worked!