[Tutor] Why does invalid syntax pop up? (fwd)
Brian van den Broek
bvande at po-box.mcgill.ca
Sat Jul 9 01:16:21 CEST 2005
Danny Yoo said unto the world upon 08/07/2005 18:14:
> [Nathan, please don't send only to me: make sure you're using "Reply to
> All" and that tutor at python.org is also being replied to. I'm actually
> going slightly crazy with work right now, but there are other people on
> the mailing list who can help.
> I'm forwarding your message to the rest of the mailing list now. Good
> ---------- Forwarded message ----------
> Date: Fri, 8 Jul 2005 16:08:53 -0600
> From: Nathan Pinno <falcon3166 at hotmail.com>
> To: Danny Yoo <dyoo at hkn.eecs.berkeley.edu>
> Subject: Re: [Tutor] Why does invalid syntax pop up?
> Here's another:
> Traceback (most recent call last):
> File "D:\password.py", line 73, in ?
> File "D:\password.py", line 41, in add_login_command
> sitelist[site] = [id,passcard]
> NameError: global name 'sitelist' is not defined
if you take a look at my examples with the function I called
name_dropper() that might help you understand this. The problem here
is that you have only ever assigned anything to sitelist within the
body of your various functions. So, the name doesn't 'have meaning' at
the global level.
I see from the code I sniped that you dealt with the last problem by
removing the spurious arguments from the function definition. But I
also notice you left them in in other functions with exactly the same
I suggest you go through your functions and verify, for each of your
arguments, that you are actually using them. Once done that, go
through and check that any assignments made within functions are
propagated out of them if they are needed in body code. (That was the
point of the top_level_name = name_keeper() example I gave.
More information about the Tutor