Simple Python problem...

Douglas Harber (dh@triple-i.com)
Tue, 14 Feb 1995 00:20:17 GMT

..but of course, I've been unable to solve it!

I'm under the impression that I should be able to use a global value
a function defined in a module, but for the life of me I can't get it
to work! I know I must be missing something trivially stupid, so could
somebody set me straight.

In a module, say foo.py, I've got:

import sys

seqno = 0

def SomeFunc():
print 'Using serial #' + seqno
seqno = seqno+1

In Python, I incant:
>>>import foo
>>>foo.SomeFunc()

after which I receive a:
NameError: seqno

This also happens if I try:
>>>from foo import *
>>>SomeFunc()

(Note: Just to be sure, I actually typed in the above module and
commands. They failed the same way as my real module.)

Okay, so far, Python's great. I love it. (I'm using the Win32
version under Windows NT.) What am I missing?

Thanks for any and all help!
Doug Harber