So verwenden Sie Setattr Python

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
Blue Cloud: Weird Coder