Message256572
| Author |
curioswati |
| Recipients |
abarnert, abarry, curioswati, rhettinger |
| Date |
2015年12月17日.03:15:37 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1450322138.83.0.0383321825059.issue25864@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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)) |
|
History
|
|---|
| 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 |
|