I have a class (bot), which has an attribute "health"; since there are a lot of parameters to this class, and I wished for the user to input a lot of them, I chose to loop through a dict of {param:explanation}, and for each param, input a value to set.
attr_array = ["health",...]
attr_dict = {}
attr_dict["health"] = "your bot's health"
...
for attr in attr_array:
tmp_attr = input(attr + attr_dict[attr] + ": ")
setattr(tmp_bot, attr_dict[attr], tmp_attr)
print attr, getattr(tmp_bot, attr_dict[attr])
print str(tmp_bot.health) + " hp"
So, the print attr, getattr... line returns (sample) "health 50"
However, the print str line returns "0 hp"
Is there any reason for this to happen?