Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copying configobj #115

Closed
FlavioAlexander opened this issue Jul 19, 2016 · 5 comments
Closed

Copying configobj #115

FlavioAlexander opened this issue Jul 19, 2016 · 5 comments

Comments

@FlavioAlexander
Copy link

Hello,

Is there a way to copy the configobj instance? I know there there is a copy method, but it returns a type dict. I want to be able to modify the copy and return its result without affecting the original object.

Best,

Flavio

@jhermann
Copy link
Collaborator

Use merge to copy the values into a new, empty ConfigObj.

@FlavioAlexander
Copy link
Author

@jhermann Thanks for your response. I have tried merge. However, if I modify the new copy, e.g. delete a section, the original 'configobj object' gets modified as well.

@jhermann
Copy link
Collaborator

Looking at the code, mutable objects (sections) are copied as-is; means you need to apply deepcopy to untangle the two objects fully.

@FlavioAlexander
Copy link
Author

I ended up deepcopying section by section and it worked, thanks for your help.

@jhermann
Copy link
Collaborator

Keeping this open to either document it, or add it to the code (possibly as a keyword param of merge()).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants