Google Model Attribute get by name
Can I get a google model attribute by passing a string to some function?开发者_开发百科
To illustrate:
If I were to do.properties().keys()
, it would return all the attributes as a list of strings.
If 'Person'
is a model and 'age'
is an attribute of person, I would like to do something like this:
Person.properties()['age'] = 25
where I set the person's age to 25
Use Python's setattr
:
setattr(a_person, 'age', 25)
精彩评论