django - python: send value of a variable instead of its name to function -


i have class this:

class rank (models.model):       respect=models.integerfield(max_length=3)       #some other attributes 

rank has many attributes (the first of respect).

the names of attributes of rank stored in list, attributes.

i iterate through them, setting them somevalue, arbitrary variable.

i'm attempting:

rank=rank() att in attributes:      rank.att=somevalue #i want rank.(value of att) instead of 

i think you're trying set value attribute name. setattr built in method for.

rank=rank() att in attributes:      setattr(rank, att, somevalue) 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -