import copy
- x = copy.copy(y) # make a shallow copy of y
- x = copy.deepcopy(y) # make a deep copy of y
+ x = copy.copy(y) # make a shallow copy of y
+ x = copy.deepcopy(y) # make a deep copy of y
+ x = copy.replace(y, a=1, b=2) # new object with fields replaced, as defined by `__replace__`
For module specific errors, copy.Error is raised.
pass
error = Error # backward compatibility
-__all__ = ["Error", "copy", "deepcopy"]
+__all__ = ["Error", "copy", "deepcopy", "replace"]
def copy(x):
"""Shallow copy operation on arbitrary Python objects.
copy.replace(c, x=1, error=2)
+class MiscTestCase(unittest.TestCase):
+ def test__all__(self):
+ support.check__all__(self, copy, not_exported={"dispatch_table", "error"})
+
def global_foo(x, y): return x+y