assign class to a variable in python code example
Example 1: how to assign a variable to a class in python
class Shark:
animal_type = "fish"
location = "ocean"
followers = 5
new_shark = Shark()
print(new_shark.animal_type)
print(new_shark.location)
print(new_shark.followers)
Example 2: python set class variable
class MyClass:
static_elem = 123 # This is a static element belonging to the class
def __init__(self):
self.object_elem = 456 # This is an instance / object element