Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #3678 -- Implemented SortedDict.copy().

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4688 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 22178d692a651be21fa9347502babe1bd17aabf2 1 parent fcd119b
@malcolmt malcolmt authored
View
7 django/utils/datastructures.py
@@ -92,6 +92,13 @@ def value_for_index(self, index):
"Returns the value of the item at the given zero-based 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):
pass
View
2  tests/regressiontests/datastructures/tests.py
@@ -50,6 +50,8 @@
>>> d['one'] = 'not one'
>>> d['one']
'not one'
+>>> d.keys() == d.copy().keys()
+True
### DotExpandedDict ############################################################

0 comments on commit 22178d6

Please sign in to comment.
Something went wrong with that request. Please try again.