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
Post a Comment