[issue31322] SimpleNamespace deep copy
Eric Snow
report at bugs.python.org
Fri Sep 1 11:08:12 EDT 2017
Eric Snow added the comment:
Hmm. What problems are you seeing with deep copies? copy.deepcopy() should work since SimpleNamespace is picklable. [1][2] I don't have any problems:
>>> import types, copy
>>> ns = types.SimpleNamespace(x=1, y=2)
>>> copied = copy.deepcopy(ns)
>>> copied
namespace(x=1, y=2)
>>> ns = types.SimpleNamespace(x=types.SimpleNamespace(a=1),
y=types.SimpleNamespace(b=2))
>>> copied = copy.deepcopy(ns)
>>> copied
namespace(x=namespace(a=1), y=namespace(b=2))
>>> ns.x is copied.x
False
[1] issue #15022
[2] https://docs.python.org/3/library/copy.html
----------
nosy: +eric.snow
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31322>
_______________________________________
More information about the Python-bugs-list
mailing list