Ticket #3964: SortedDict__repr__.diff

File SortedDict__repr__.diff, 713 bytes (added by Forest Bond <forest@…>, 8 years ago)

patch implementing SortedDict.repr

  • django/utils/datastructures.py

     
    9999        obj.keyOrder = self.keyOrder
    100100        return obj
    101101
     102    def __repr__(self):
     103        '''Returns string representation of d.  The Python default for dicts
     104        doesn't seem to use keys().  We just re-implement it as an iterator
     105        over self so that the representation appears to have the correct order.
     106        '''
     107        return '{%s}' % ', '.join(
     108          '%s: %s' % (repr(k), repr(self[k])) for k in self)
     109
    102110class MultiValueDictKeyError(KeyError):
    103111    pass
    104112
Back to Top