Django

Code

Changeset 5069

Show
Ignore:
Timestamp:
04/25/07 02:30:54 (1 year ago)
Author:
mtredinnick
Message:

Fixed #3964 -- Added a custom SortedDict.repr so that the keys are printed
in sorted order. Based on a patch from Forest Bond.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/utils/datastructures.py

    r5068 r5069  
    9999        obj.keyOrder = self.keyOrder 
    100100        return obj 
     101 
     102    def __repr__(self): 
     103        """ 
     104        Replaces the normal dict.__repr__ with a version that returns the keys 
     105        in their sorted order. 
     106        """ 
     107        return '{%s}' % ', '.join(['%r: %r' % (k, v) for k, v in self.items()]) 
    101108 
    102109class MultiValueDictKeyError(KeyError): 
  • django/trunk/tests/regressiontests/datastructures/tests.py

    r4688 r5069  
    5353>>> d.keys() == d.copy().keys() 
    5454True 
     55>>> print repr(d) 
     56{'one': 'not one', 'two': 'two', 'three': 'three'} 
    5557 
    5658### DotExpandedDict ############################################################