Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Pickling an instance of a class containing a dict doesn't work
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Marco Lierfeld, post: 2039594"] Hello there, I want to save an instance of a class containing a dictionary with the pickle-module. The class looks like this: class subproject: configuration = {} build_steps = [] # some functions # ... Now I create an instance of this class, e.g. test = subproject() and try to save it with pickle.dump(test, file('test.pickle','wb')) or with pickle.Pickler(file('test.pickle','wb')).save(test) it looks like everything has worked well, but in the saved file 'test.pickle' only the list 'build_steps' is saved - the dictionary 'configuration' is missing. There is wether an error-message nor an exception. When I try to save only the dictionary, there is no problem at all - the dict is saved to the file. I also tried the 3 different protocols (0, 1, 2), but none of them worked for me. I hope somebody knows what to do ;) Thanks for reading Marco [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Pickling an instance of a class containing a dict doesn't work
Top