Store a variable permanently

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Mar 1 04:44:30 CET 2013


On Thu, 28 Feb 2013 19:35:57 -0800, eli m wrote:

> 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?

You have to write it to a file, then read it back in when the program 
starts.

Do you need help with reading and writing files?

Perhaps the easiest way to do this is with the configparser or plistlib 
modules.

http://docs.python.org/2/library/configparser.html
http://docs.python.org/2/library/plistlib.html


-- 
Steven



More information about the Python-list mailing list