If I'm understanding your situation correctly, what you're seeing is the result of how Python handles local (function) and global (module) namespaces.
Say you've got a module like this:
# sample.py
myGlobal = 5
def func1():
myGlobal = 42
def func2():
print myGlobal
func1()
func2()
But it'll prints 5 instead of 42.
As it's already mentioned that, if you add a 'global' declaration to func1(), then func2() will print 42.
def func1():
global myGlobal
myGlobal = 42
In the above code, Python assumes that any name that is assigned to, anywhere within a function, is local to that function unless explicitly told otherwise. If it is only reading from a name, and the name doesn't exist locally, it will try to look up the name in any containing scopes (e.g. the module's global scope).