MCPcopy Create free account
hub / github.com/ActiveState/code / copy

Method copy

recipes/Python/579113_defdict/recipe-579113.py:211–223  ·  view source on GitHub ↗

Return shallow copy of dictionary. >>> dd = DefDict.fromkeys(range(5), 5) >>> ddcopy = dd.copy() >>> print ddcopy._default, isinstance(ddcopy, DefDict); print ddcopy 5 True {0: 5, 1: 5, 2: 5, 3: 5, 4: 5} >>> ddcopy[0] = 7 >>> print dd[0], ddco

(self)

Source from the content-addressed store, hash-verified

209 return dict.get(self, key, *args)
210
211 def copy(self):
212 """Return shallow copy of dictionary.
213
214 >>> dd = DefDict.fromkeys(range(5), 5)
215 >>> ddcopy = dd.copy()
216 >>> print ddcopy._default, isinstance(ddcopy, DefDict); print ddcopy
217 5 True
218 {0: 5, 1: 5, 2: 5, 3: 5, 4: 5}
219 >>> ddcopy[0] = 7
220 >>> print dd[0], ddcopy[0]
221 5 7
222 """
223 return self.__class__(self, self._default)
224
225 __copy__ = copy
226

Callers 4

flipEdgesMethod · 0.45
edge_coloringFunction · 0.45
wrapperMethod · 0.45
copy_fileFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected