title: How to fix circular import here?
body: <p>I have two files <code>mainfile.py</code> and <code>lists.py</code>. <code>mainfile.py</code> has a class <code>Foo</code> with methods that depend on lists. So I'll feed some lists from <code>lists.py</code> to it. But one of the lists from <code>lists.py</code> will have an element that uses a method from class <code>Foo</code> in <code>mainfile.py</code>. Something like this:</p>
  <pre><code># mainfile.py
  import lists
  
  list_1 = lists.list_1
  list_2 = lists.list_2
  
  class Foo:
      method_1(lst1, lst2, lst3):
          pass
          # does stuff with those lists
  
      method_2():
          pass
          # will be used on lists.py
  
  </code></pre>
  <pre><code># lists.py
  import mainfile
  
  list_1 = ['a', 'b', 'c']
  list_2 = ['depending', 'on', mainfile.Foo.method2(), 'method']
  </code></pre>
  <p>Initially I was doing <code>from mainfile import Foo</code>. However, I changed it to just <code>import Foo</code> just like an answer here on SO said. But it still does not work. When running <code>mainfile.py</code>:</p>
  <blockquote>
  <p>AttributeError: partially initialized module 'lists' has no attribute 'list_1' (most likely due to a circular import)</p>
  </blockquote>
  <p>I've tried moving the <code>import</code> to the end of <code>lists.py</code>, but then <code>mainfile</code> in <code>mainfile.Foo.method2()</code> is not defined.</p>
  <p><strong>What should I do here? refactor something? or am I importing those files the wrong way?</strong></p>
  <p>P.S. I'd do this all in one file, but <code>lists.py</code> will eventually have a lot of lists in it, so I'd rather keep it separate.</p>