Closed betezed closed 9 years ago
Sometimes, you need to access some attributes with variables containing the attribute's name, instead of accessing it directly (sorry for my english, btw) For exemple :
class obj():
attr = 1
def getkey(obj, key):
return obj().key
print(getkey(obj(), "attr")) # Output : AttributeError: obj instance has no attribute 'key'
Please append the ".py" suffix to your file and add yourself to the contributors.
Why not just use obj().attr ?