Ticket #10370: mvd_itervalues.diff

File mvd_itervalues.diff, 1.2 KB (added by Ryan Kelly, 16 years ago)

re-implement MultiValueDict.itervalues()

  • django/utils/datastructures.py

     
    287287        """Returns a list of the last value on every key list."""
    288288        return [self[key] for key in self.keys()]
    289289
     290    def itervalues(self):
     291        """Yield the last value on every key list."""
     292        for list_ in super(MultiValueDict,self).itervalues():
     293            yield list_[-1]
     294
    290295    def copy(self):
    291296        """Returns a copy of this object."""
    292297        return self.__deepcopy__()
  • tests/regressiontests/datastructures/tests.py

     
    5858>>> d.setlist('lastname', ['Holovaty', 'Willison'])
    5959>>> d.getlist('lastname')
    6060['Holovaty', 'Willison']
     61>>> d.values()
     62['Developer', 'Simon', 'Willison']
     63>>> list(d.itervalues())
     64['Developer', 'Simon', 'Willison']
    6165
    6266### SortedDict #################################################################
Back to Top