variable attribute name

Harvey Greenberg hjgreenberg at gmail.com
Mon Oct 27 14:23:16 EDT 2014


I want to let the name of an attribute be the string value of a variable.  Here is some code:

class Object(object): pass
A = Object()
s = 'attr'
A.<s> = 1

The last line denotes the variable value by <s> (not a python form).  What I want is to have A.attr = 1, but 'attr' determined by the value of s.  Please advise.



More information about the Python-list mailing list