class Food():
breakfast = "Pancakes"
Lunch = "Sandwich"
#Parts of setattr
#self: what class or object
#name: the variable you are affecting
#value: what the variable's value will be
setattr(Food,"breakfast","Toast")
print(Food.breakfast)
>>Toast
#You can also add a variable
setattr(Food,"Dinner","Steak")
print(Food.Dinner)
>>Steak
# Per https://www.w3schools.com/python/ref_func_setattr.asp,
# the setattr() function sets the value of the specified attribute of the specified object.
# Here is a sample code from https://www.w3schools.com/python/trypython.asp?filename=demo_ref_setattr
class Person:
name = "John"
age = 36
country = "Norway"
setattr(Person, 'age', 40)
# The age property will now have the value: 40
x = getattr(Person, 'age')
print(x)