[Tutor] Databases in Python

aug dawg augdawg09 at gmail.com
Tue Aug 24 21:35:09 CEST 2010


Oh, stupid me forgot the error message. Well, for some odd reason it works
now, but there are still some issues. When I tried it just a few minutes
ago, it worked fine, it seemed to me.
If anyone have any tips, please let me know. Thanks everyone for the tips.

On Tue, Aug 24, 2010 at 2:24 PM,
<christopher.henk at allisontransmission.com>wrote:

>
>
> aug dawg <augdawg09 at gmail.com> wrote on 08/24/2010 01:55:14 PM:
>
>
> > Now it says that the variable adder is not defined. Does anyone know
> about this?
> >
> It is best if you send the full error message, it helps pinpoint the
> problem.
> my copy of your code was:
> database = []
> datafile = open('/home/~/the-db/data')
> for line in datafile:
> database.append(line)
>
> while tf2 != True:
> command = raw_input("Enter a command. >> ")
>
> while tf != True:
> if "add" in command:
> adder = raw_input("What to add? >> ")
> data_base.append(adder)
> if "no more" in adder:
> tf = True
>
> if "read" in command:
> print(database)
> if "search" in command:
> searcher = raw_input("Enter term to search >> ")
> if searcher in database:
> # Figure this out.
> if "exit database" in command:
> print "Bye!"
> sys.exit()
>
> I am not sure what you typed in as your command or how your source was
> formatted (the tabs did not come through to me) so I cannot say for sure.
> If "add" was not your command, adder does not get defined.
> My guess is that you typed in a different command so you skipped the
> assignment but are checking for "no more" in adder, or attempting to append
> adder.  This would trigger that error.  Did you get the "What to add? >>"
> message?
>
> Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100824/c7edee51/attachment.html>


More information about the Tutor mailing list