I'm pretty sure that Foo is getting replaced once you import Foo, why not pass the Foo() object to bar's go? I'm sure there are other ways, but yes, circular imports are indeed evil.<br>
<br><br><div class="gmail_quote">On Thu, Feb 26, 2009 at 5:13 PM, Chris Rebert <span dir="ltr"><<a href="mailto:clp2@rebertia.com">clp2@rebertia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d">On Thu, Feb 26, 2009 at 1:48 PM, Jesse Aldridge <<a href="mailto:JesseAldridge@gmail.com">JesseAldridge@gmail.com</a>> wrote:<br>
> I have one module called foo.py<br>
> ---------------------<br>
> class Foo:<br>
>    foo = None<br>
><br>
> def get_foo():<br>
>    return Foo.foo<br>
><br>
> if __name__ == "__main__":<br>
>    import bar<br>
>    Foo.foo = "foo"<br>
>    bar.go()<br>
> ---------------------<br>
> And another one called bar.py<br>
> ---------------------<br>
> import foo<br>
><br>
> def go():<br>
>    assert foo.get_foo() == "foo"<br>
> ----------------------<br>
> When I run foo.py, the assertion in bar.py fails.  Why?<br>
<br>
</div>Not sure, but circular imports are *evil* anyway, so I'd suggest you<br>
just rewrite the code to avoid doing any circular imports in the first<br>
place.<br>
<br>
Cheers,<br>
Chris<br>
<font color="#888888"><br>
--<br>
Follow the path of the Iguana...<br>
<a href="http://rebertia.com" target="_blank">http://rebertia.com</a><br>
</font><div><div></div><div class="Wj3C7c">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>