diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index cecb4da170..9bec7a5df7 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -70,7 +70,7 @@ class SortedDict(dict): return self.keyOrder[:] def values(self): - return [dict.__getitem__(self,k) for k in self.keyOrder] + return [dict.__getitem__(self, k) for k in self.keyOrder] def update(self, dict): for k, v in dict.items(): @@ -81,6 +81,10 @@ class SortedDict(dict): self.keyOrder.append(key) return dict.setdefault(self, key, default) + def value_for_index(self, index): + "Returns the value of the item at the given zero-based index." + return self[self.keyOrder[index]] + class MultiValueDictKeyError(KeyError): pass