Coping with cyclic imports

Oscar Benjamin oscar.j.benjamin at gmail.com
Thu Jul 4 11:03:20 EDT 2013


On 4 July 2013 13:48,  <kanchan.n.mahajan at gmail.com> wrote:
> On Tuesday, April 8, 2008 10:06:46 PM UTC+2, Torsten Bronger wrote:
[snip]
>
> If you do "import foo" inside bar and "import bar" inside foo, it will work fine. By the time anything actually runs, both modules will be fully loaded and will have references to each other.
>
> The problem is when instead you do "from foo import abc" and "from bar import xyz". Because now each module requires the other module to already be compiled (so that the name we are importing exists) before it can be compiled.
>
> from
> http://stackoverflow.com/questions/744373/circular-or-cyclic-imports-in-python

Is there some reason you're responding to a post from 5 years ago?

Or is it just a joke that you've created a cyclic import advice link
by referring to a SO question where the top answer is actually a quote
linking back to the previous post in this same thread?


Oscar



More information about the Python-list mailing list