Steven D'Aprano added the comment:

> When using nested SimpleNamespaces, a making a copy by using 
> 
> new_NS=SimpleNamespace(**namespace.__dict__.copy())

In general, you shouldn't call or directly access dunder attributes. 
There are exceptions, but generally they're for Python's use only. For 
example, the public interface for getting __dict__ is to call 
vars(namespace).

But there's no need to do this by hand. Use the copy module instead.

copy.copy(namespace)  # copy one level only

copy.deepcopy(namespace)  # copy all the way down

seem to work for me.

Does this solve your problem? If so, we'll close this issue.

----------
nosy: +steven.daprano

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue31322>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to