Name valid outside function, but error name inside function

Fernando Rodríguez frr at mindless.com
Fri Jul 21 06:56:40 EDT 2000


Hi!

I have a rather weird problem:  I have a module (module1) that defines a
variable called A. I have another module (module2) that imports module1:
from module1 import *

In module2, A is a valid variable, but I run into trouble if I try to use
it inside a function in module2.

This works fine:
def func1():
    print A

This raises a name error:
def func2():
    A = A + 'hi'    # this line causes the error
    print A

What's going on???? O:-)

TIA
--


---------------------------------------
Fernando Rodríguez





More information about the Python-list mailing list