python get attribute name as a string code example
Example 1: python get object attribute by string
x = getattr(t, 'attr1')
setattr(t, 'attr1', 21)
Example 2: python set attribute by string name
setattr(some_object, 'some_attribute', 42)
x = getattr(t, 'attr1')
setattr(t, 'attr1', 21)
setattr(some_object, 'some_attribute', 42)