mirror of https://github.com/django/django.git
Fixed #3678 -- Implemented SortedDict.copy().
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4688 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
fcd119bfb1
commit
22178d692a
|
@ -92,6 +92,13 @@ class SortedDict(dict):
|
||||||
"Returns the value of the item at the given zero-based index."
|
"Returns the value of the item at the given zero-based index."
|
||||||
return self[self.keyOrder[index]]
|
return self[self.keyOrder[index]]
|
||||||
|
|
||||||
|
def copy(self):
|
||||||
|
"Returns a copy of this object."
|
||||||
|
# This way of initialising the copy means it works for subclasses, too.
|
||||||
|
obj = self.__class__(self)
|
||||||
|
obj.keyOrder = self.keyOrder
|
||||||
|
return obj
|
||||||
|
|
||||||
class MultiValueDictKeyError(KeyError):
|
class MultiValueDictKeyError(KeyError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,8 @@
|
||||||
>>> d['one'] = 'not one'
|
>>> d['one'] = 'not one'
|
||||||
>>> d['one']
|
>>> d['one']
|
||||||
'not one'
|
'not one'
|
||||||
|
>>> d.keys() == d.copy().keys()
|
||||||
|
True
|
||||||
|
|
||||||
### DotExpandedDict ############################################################
|
### DotExpandedDict ############################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue