NEVER MIND!

Delaney, Timothy tdelaney at avaya.com
Wed May 8 19:07:37 EDT 2002


> From: Carl [mailto:kingprad at mail.com]
> 
> I solved the problem finally by moving the location around 
> about 12 times,
> resaving and running. After 12 times it suddenly worked, 
> right before my
> head exploded with frustration.

Firstly, may I suggest that you should have posted this in reply to your
original thread, so that people will see it when they read that. My initial
thought ws that this was in response to another problem that has been
discussed recently.

Post the solution then. Also, do you understand *why* it now works? If not,
you really haven't gained anything (except a currently working program) and
so are likely to make the same mistake again - probably on this exact same
piece of code when you want to add something to it.

If you post the solution (with code), you will find lots of people here
willing to suggest ways that you could avoid this problem in the future.

The short piece of code you posted will definitely not work, because at the
line

print ch, ascii_val(ch)     # ch is just a character read from a file

ch does not exist (we haven't seen the code that binds it).

My guess it that you had code of the form ...

<imports>

<code>

<functions>

and that you called something in <functions> somewhere in <code>. This will
not work, because at the time that you try to use a name, that name must
have been bound (or you will get a NameError). Code in files are executed in
the order that they are listed - and a function definition is simply code to
be executed. Note that this is different to referring to a name bound after
a function definition - simply defining the function doesn't try to use the
name - calling the function does that.

Tim Delaney





More information about the Python-list mailing list