Imagine you have a class in python that returns:
d=[{'source_id': '1', 'source_desc': 'XML1'},
{'source_id': '2', 'source_desc': 'XML2'},
{'source_id': '3', 'source_desc': 'XML3'}]
Imagine the class is called:
class ddata():
def __init__(var):
self.var=method_class(var)
def method_class(self,v):
´´´do stuff / dummy method´´´
return v
Initializing:
mydata=ddata(d)
Is it possible in python to add a particular method to the class in order to allow the following: pseudocode:
mydata.1.source_desc (would be XML1)
EDIT The intention is that one, and only one of the keys is used as enter dot notation. in this case the numbers. the numbers are int or str. AND ARE NOT NECESSARILY consecutive, what invalidate solutions based on position on the returned list.