Is something like this possible?
class MyObject(object):
attr = 1
def fetch(ob, attr)
return ob.attr
mo = MyObject()
print fetch(mo, 'attr') #any way to do this?
#expected 1
The reason I ask is because I do know the name of attribute I will be calling, and the object has quite a few attributes and so I could do a massive if/elif
block, but that would be ugly and harder to maintain.