Функция Python setattr
class Student:
name = 'John'
student = Student()
# Set 'age' attribute to 23
setattr(student, 'age', 23)
print('Student name: ', student.name)
print('Student age: ', student.age)
# Output
# Student name: John
# Student age: 23
Glorious Gnat