python setattribute code example
Example 1: set attribute python
setattr(object, name, value)
Example 2: python setattr
class Person:
name = 'Adam'
p = Person()
print('Before modification:', p.name)
# setting name to 'John'
setattr(p, 'name', 'John')
print('After modification:', p.name)