Is there a way to implement an equivalent of the item method shown below, which gives the same functionality without copying all the data or looping? So in this example it would return ('bar', 20).
from collections import OrderedDict class MyOrderedDict(OrderedDict): def item(self, index): return list(self.items())[index] d = MyOrderedDict() d["foo"] = 10 d["bar"] = 20 d["baz"] = 25 print(d.item(1))
list;)