Two ways to add attributes to a class
The first one is : Through functions
def add_name(name,cls):
cls.NAME = name
class Person:
AGE = 3
add_name(name="TOM",cls=Person)
print(Person.NAME)
result :
TOM
The second is realized by decorator
def setnamepropery(name):
def wrapper(cls):
cls.NAME=name
return cls
return wrapper
@setnamepropery('TOM') #setnamepropery=setnamepropery(Person)
class Person:
AGE =3
print(Person.NAME)
result
TOM