title: Understanding `from ... import ...` behavior
body: <p>I've encountered an interesting behavior regarding the <code>from ... import ...</code> syntax. It seems that when using this syntax, identifiers are imported as new identifiers, instead of references.</p>
  
  <p>I've been writing Python for quite some time and have always avoided using this syntax, so this is quite unexpected for me. Instead I expected it to work the same as <code>import ...</code>.</p>
  
  <p>Here is an example:</p>
  
  <p>a.py</p>
  
  <pre><code>x = 0
  </code></pre>
  
  <p>b.py</p>
  
  <pre><code>from b import x
  
  def f():
      print(x)
  </code></pre>
  
  <p>main.py</p>
  
  <pre><code>import a
  import b
  
  a.f()
  b.x = 1
  a.f()
  </code></pre>
  
  <p>The result is:</p>
  
  <pre><code>0
  0
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>0
  1
  </code></pre>
  
  <p>which I expected.</p>
  
  <p>So does <code>from ... import ...</code> create a new variable, or does it make a reference to the variable?</p>
  
  <p>I've searched the docs, Googled, searched around StackOverflow, but there doesn't seem to be a very clear answer to this question. Any links (especially Python docs) would be appreciated.</p>