title: Why does code like `str = str(...)` cause a TypeError, but only the second time?
body: <p>I have some code like:</p>
  <pre><code>def example(parameter):
      global str
      str = str(parameter)
      print(str)
  
  example(1)
  example(2)
  </code></pre>
  <p>The first call to <code>example</code> works, but then the second time around I get an error like:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;test.py&quot;, line 7, in &lt;module&gt;
      example(2)
    File &quot;test.py&quot;, line 3, in example
      str = str(parameter)
  TypeError: 'str' object is not callable
  </code></pre>
  <p>Why does this happen, and how can I fix it?</p>
  <hr />
  <p><sub>If you are in an interactive session and encountered a problem like this, and you want to fix the problem without restarting the interpreter, see <a href="https://stackoverflow.com/questions/17152760">How to restore a builtin that I overwrote by accident?</a>.</sub></p>