Can someone explain this behavior to me?

Jesse Aldridge JesseAldridge at gmail.com
Thu Feb 26 16:48:08 EST 2009


I have one module called foo.py
---------------------
class Foo:
    foo = None

def get_foo():
    return Foo.foo

if __name__ == "__main__":
    import bar
    Foo.foo = "foo"
    bar.go()
---------------------
And another one called bar.py
---------------------
import foo

def go():
    assert foo.get_foo() == "foo"
----------------------
When I run foo.py, the assertion in bar.py fails.  Why?



More information about the Python-list mailing list