Minor text rearrangement.

This commit is contained in:
Raymond Hettinger 2011-04-20 13:11:38 -07:00
parent ffdf94ae79
commit 3674c8591f
1 changed files with 10 additions and 10 deletions

View File

@ -112,16 +112,6 @@ class OrderedDict(dict):
yield curr[KEY] yield curr[KEY]
curr = curr[PREV] curr = curr[PREV]
def __reduce__(self):
'Return state information for pickling'
items = [[k, self[k]] for k in self]
inst_dict = vars(self).copy()
for k in vars(OrderedDict()):
inst_dict.pop(k, None)
if inst_dict:
return (self.__class__, (items,), inst_dict)
return self.__class__, (items,)
def clear(self): def clear(self):
'od.clear() -> None. Remove all items from od.' 'od.clear() -> None. Remove all items from od.'
try: try:
@ -190,6 +180,16 @@ class OrderedDict(dict):
return '%s()' % (self.__class__.__name__,) return '%s()' % (self.__class__.__name__,)
return '%s(%r)' % (self.__class__.__name__, self.items()) return '%s(%r)' % (self.__class__.__name__, self.items())
def __reduce__(self):
'Return state information for pickling'
items = [[k, self[k]] for k in self]
inst_dict = vars(self).copy()
for k in vars(OrderedDict()):
inst_dict.pop(k, None)
if inst_dict:
return (self.__class__, (items,), inst_dict)
return self.__class__, (items,)
def copy(self): def copy(self):
'od.copy() -> a shallow copy of od' 'od.copy() -> a shallow copy of od'
return self.__class__(self) return self.__class__(self)