Re: Global variables in modules...

2008-03-28 Thread Terry Jones
> "Peter" == Peter Otten <[EMAIL PROTECTED]> writes: Peter> [EMAIL PROTECTED] wrote: [snip] >> ...can someone explain why invoking a.py prints 0? >> I would have thought that the global variable 'g' of module 'a' would >> be set to 1... Peter> When you run a.py as a script it is put into the s

Re: Global variables in modules...

2008-03-28 Thread ttsiodras
That clears it up. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Global variables in modules...

2008-03-28 Thread Peter Otten
[EMAIL PROTECTED] wrote: > With a.py containing this: > > == a.py === > #!/usr/bin/env python > import b > > g = 0 > > def main(): > global g > g = 1 > b.callb() > > if __name__ == "__main__": > main() > == > > ...and b.py containing...

Global variables in modules...

2008-03-28 Thread ttsiodras
With a.py containing this: == a.py === #!/usr/bin/env python import b g = 0 def main(): global g g = 1 b.callb() if __name__ == "__main__": main() == ...and b.py containing... = b.py = import a, sys def callb():