mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
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
|
||||
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):
|
||||
pass
|
||||
|
||||
|
@ -52,6 +52,8 @@
|
||||
'not one'
|
||||
>>> d.keys() == d.copy().keys()
|
||||
True
|
||||
>>> print repr(d)
|
||||
{'one': 'not one', 'two': 'two', 'three': 'three'}
|
||||
|
||||
### DotExpandedDict ############################################################
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user