[Tutor] Why does invalid syntax pop up? (fwd)

Nathan Pinno falcon3166 at hotmail.com
Sat Jul 9 09:26:17 CEST 2005

Hey all, 

Just a notice, I'm quitting work on this program, too complicated for me to
work out, I'm getting lost now and can't figure out the bugs anymore. I
think for know I'll work on my Giant Calculator application, which I'll show
the code when it's done. If anyone is interested in finishing it, just give
me a shout, and I'll send it to you as a ZIP file.

Nathan Pinno
Crew, McDonalds Restaurant, Camrose, AB, Canada

-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On Behalf
Of Brian van den Broek
Sent: July 8, 2005 5:16 PM
Cc: Tutor
Subject: Re: [Tutor] Why does invalid syntax pop up? (fwd)

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 
> luck!]
> ---------- 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 ?
>       add_login_command()
>     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 problem.

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.


Brian vdB

Tutor maillist  -  Tutor at python.org

More information about the Tutor mailing list