Store a variable permanently

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Feb 28 22:44:30 EST 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