Global variables in modules...

ttsiodras at ttsiodras at
Fri Mar 28 14:29:21 CET 2008

With containing this:

========== ===========
#!/usr/bin/env python
import b

g = 0

def main():
    global g
    g = 1

if __name__ == "__main__":

...and containing...

========= =============
import a, sys

def callb():
    print a.g

...can someone explain why invoking prints 0?
I would have thought that the global variable 'g' of module 'a' would
be set to 1...

More information about the Python-list mailing list