Fixed #3964 -- Added a custom SortedDict.__repr__ so that the keys are printed
in sorted order. Based on a patch from Forest Bond. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5069 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
535535a45e
commit
aca569804e
|
@ -99,6 +99,13 @@ class SortedDict(dict):
|
||||||
obj.keyOrder = self.keyOrder
|
obj.keyOrder = self.keyOrder
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
"""
|
||||||
|
Replaces the normal dict.__repr__ with a version that returns the keys
|
||||||
|
in their sorted order.
|
||||||
|
"""
|
||||||
|
return '{%s}' % ', '.join(['%r: %r' % (k, v) for k, v in self.items()])
|
||||||
|
|
||||||
class MultiValueDictKeyError(KeyError):
|
class MultiValueDictKeyError(KeyError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@
|
||||||
'not one'
|
'not one'
|
||||||
>>> d.keys() == d.copy().keys()
|
>>> d.keys() == d.copy().keys()
|
||||||
True
|
True
|
||||||
|
>>> print repr(d)
|
||||||
|
{'one': 'not one', 'two': 'two', 'three': 'three'}
|
||||||
|
|
||||||
### DotExpandedDict ############################################################
|
### DotExpandedDict ############################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue