[Tutor] saving program
alan.gauld at blueyonder.co.uk
Thu Sep 2 09:07:03 CEST 2004
> good afternoon. I was wondering if there was a way to make
> a program save the info it gives so when you open it again
> it displays the information that was last inputed into the
Hmm, there are a couple of possibilities here.
Do you mean you want to save the data that the user of your
program entered, ie that was captured via raw_input() say,
or from reading a file?
Do you mean you want to save the program commands that you
have typed in at the >>> prompt iusing IDLE or Pythonwin??
If the first then you have to write code to save the data
into a file and then read it back when your program restarts.
If the second then you have to type your program into a
new text file (with name ending in .py). IDLE can create
those for you from the File->New menu, and you just save
the file when you are finished. Next time you start IDLE
use File->Open to read it again and carry on working from
where you left off..
> So you don't have to start fresh everytime you start the program.
I'm guessing from this you are meaning the second scenario
but I'm not sure. If you are following my tutorial then I
cover this in the "More Sequences" topic. I also cover saving
data to files in the "Handling Files" topic!
Author of the Learn to Program web tutor
More information about the Tutor