Python используйте строку, чтобы получить атрибуты объекта

#There are built-in functions called getattr and setattr
getattr(object, attrname)
setattr(object, attrname, value)
Classy Answer