Message256572
But the work around suggested here as:
def __reversed__(self):
return (self[k] for k in reversed(range(len(self))))
is also not a general solution, i.e. it is applicable for the following case:
m = MyDict({2:40, 0:10, 1:20})
but for any other mapping which does not have 0 as a key, it results in KeyError. So another solution, which would be more general could be:
def __reversed__(self):
keys = [k for k in self.keys()]
return (self[k] for k in reversed(keys)) |
|
Date |
User |
Action |
Args |
2015-12-17 03:15:38 | curioswati | set | recipients:
+ curioswati, rhettinger, abarnert, abarry |
2015-12-17 03:15:38 | curioswati | set | messageid: <1450322138.83.0.0383321825059.issue25864@psf.upfronthosting.co.za> |
2015-12-17 03:15:38 | curioswati | link | issue25864 messages |
2015-12-17 03:15:38 | curioswati | create | |
|