I'm trying to assign class variables at runtime based on key/value pairs in a dictionary, where the key is what is called, and the value refers to the variable to be set.
keys = {'hours':'hours', 'minutes':'minutes'}
hours = 0
minutes = 0
def set_time(self, key, value):
self.keys[key] = value
set_time
, will not be a simple setter, but will take value
as a string and convert it to integer minutes or hours. I want to look up the correct variable name based on the key
parameter, but this code changes the value of the dictionary entry instead. Tried to search google and SO, but don't know the words to describe what I'm trying to find.