Store a variable permanently

Jean-Michel Pichavant jeanmichel at
Fri Mar 1 11:19:22 CET 2013

----- Original Message -----
> So i have a variable called funds that i want to store the value of
> even after the program is exited. My funds variable holds the total
> value of funds i have. I add a certain number of funds each time i
> run the program by entering how much i want to add. How would i
> store the funds variable to keep its value?
> --


I would serialize the data.

pickle.dump(funds, 'funds.pickle')

# to reload funds:

funds = pickle.load('funds.pickle')

The good thing with pickle is that it serializes a lot of things, see the "What can be pickled" section of the doc.



The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

More information about the Python-list mailing list