Home > Software engineering >  How can I change an attribute of an object using something the user has entered?
How can I change an attribute of an object using something the user has entered?

Time:06-01

I know about using print(object, attribute_choice)) to print an attribute but is there a similar possibility to change it? attribute_choice is enterd by the user.

CodePudding user response:

Use setattr(obj, "myattr", "new_value").

  • Related