On Feb 27, 8:48 am, Jesse Aldridge <jessealdri...@gmail.com> wrote: > 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?
AFAICT from that convoluted mess, because there are two rabbit holes, __main__.Foo.foo and foo.Foo.foo, and you poked "foo" down the wrong one. In any case the other one is not the right one -- as you have already been advised, circular imports are evil. -- http://mail.python.org/mailman/listinfo/python-list