[Tutor] Storing Info

Michael Williams michael.williams@st-annes.oxford.ac.uk
Wed, 17 Apr 2002 16:36:18 +0100


On Wed, Apr 17, 2002 at 04:24:28PM +0100, Crane, Adam wrote:
> I'm attempting to write a program that stores/remembers a users input when
> it is run.  It's a Notes/Reminder program.
> 
> So far I have this code (not tried or tested):
> 
> print "Notes Program."
> print "Type in "null" if you do not wish to add a note."
> 
> notes = raw_input("Enter a note/Reminder:")
> while notes <= "":
> 	print "That's a rather short note!"
> 	notes = raw_input("Enter a note/Reminder:")
> if notes == "null"
> 	break
> 
> So what I need to do is store the users input for future reference.  I'm
> starting to think I'm in way over my head.  I was thinking maybe I'd have to
> import the info, or something similar (I have no idea)
> 
> Any help would be great.

How you handle this depends largely on whether the program is going to
be running permenantly in the background, or is going to be stopped and
started. If the latter you need to store the notes' text in files for
later access. Take a look at the file tutorial in the official Python
tutorial

<http://www.python.org/doc/current/tut/node9.html>

Similar guides can be found on the other online tutorials. You will
probably need to do some string manipulation too:

<http://www.python.org/doc/current/lib/module-string.html>

-- 
Michael