Assignment build in functions
<p>I found an example which make me curious:</p>

<pre><code>int = float
def parse_string(s):
    return int(s)
print(parse_string('42')) 
</code></pre>

<p>The returned result is <code>42.0</code>. Int and float are build in functions. How come that we can assign float to int (build in functions)? It seems to be wired to me. </p>

<p>Python use references to objects.</p>

<p>When you write <code>int = float</code>, you only change the <code>int</code> reference to point to the same object (a built-in function here) than the one pointed by <code>float</code> reference.</p>

<p>You don't change the nature of <code>int</code> of course.</p>

<p>You can restore the <code>int</code> reference by importing <strong><a href="https://docs.python.org/2/library/__builtin__.html" rel="nofollow">__builtin__</a></strong>:</p>

<pre><code>import __builtin__

int = __builtin__.int
</code></pre>

python