won't recognize functions in script

Carl kingprad at mail.com
Wed May 8 17:19:40 EDT 2002


I've never had this problem before and I've been using ActivePython for
months on XP with no problems (except its inability to control-break running
programs...).

I'm writing a simple text file processing program which at this stage just
is reading characters and getting their ascii values. When I define
functions python gives me 'NameError: name 'ascii_val' is not defined'

this piece of my code is this:


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

def ascii_val(char):
    # returns 1-26 for A-Z or 27 for a space
    x = ord(char) - 96
    if x == -64:
        return 27
    else:
        assert(x >= 1 and x<=26)
        return x

and it gives me the NameError. It does this with _all_ of my def functions.
I've tried changing their names, locations in the file, moving everything to
a new file, exiting and restarting, rebooting. When I quickly write a
generic program to see if a def function works there are no problems, and
all my old programs work.

Can anyone guess what's happening? Thanks for any help you can offer!

Carl Scharenberg
kingprad at mail.com





More information about the Python-list mailing list