title: Why does print(sys.modules['__main__']) in bar.py produces the same output?
body: <pre><code>#foo.py
  import bar
  import sys
  print(sys.modules['__main__'])
  </code></pre>
  
  <pre><code>#bar.py
  import foo
  import sys
  print(sys.modules['__main__'])
  </code></pre>
  
  <p>When foo.py was run, the output was the following:</p>
  
  <p><a href="https://i.stack.imgur.com/gP3w5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gP3w5.png" alt="Output"></a></p>
  
  <p>So why does <code>print(sys.modules['__main__'])</code> in <code>bar.py</code> produces the same output? Can someone please explain to me how did the execution take place?</p>