meaning of assignment operator in python2.7
<p>i do the following:</p>

<pre><code>a=12345
</code></pre>

<p>I am trying to undertstand the meaning of this.Please answer below questions.</p>

<ol>
<li><p>a points to the memory address of 12345
(True/False)</p></li>
<li><p>If i do b=12345. Then b also points to the memoery address of 12345
(True/False)</p></li>
<li><p>I have read that the ref count of 12345 should increase by 1 after b points to it.
(True/False)</p></li>
<li><p>How can i retrieve the memory address of 12345. I want to check that a and b both point to address of 12345.Please clarify</p></li>
</ol>

<p>I tried using id function(it only show same memory location for &lt;=255 range)</p>

<ol>
<li><p><em>"a points to the memory address of 12345 (True/False)"</em></p>

<p>True.</p></li>
<li><p><em>"If i do b=12345. Then b also points to the memoery address of 12345 (True/False)"</em></p>

<p>Maybe.  If you had assigned <code>b=a</code>, the <code>b</code> would point to the same memory location as <code>a</code>.  With <code>b=12345</code>, the answer is unknown: there may be more than one copy of <code>12345</code> in memory.</p></li>
<li><p><em>"I have read that the ref count of 12345 should increase by 1 after b points to it. (True/False)"</em></p>

<p>True if <code>a</code> and <code>b</code> pointed to the same location: see above.</p></li>
<li><p><em>"How can i retrieve the memory address of 12345. I want to check that a and b both point to address of 12345.  Please clarify."</em></p>

<p>To check if <code>a</code> and <code>b</code> point to the same memory location, use <code>is</code> as in <code>a is b</code>.  For example, in the following, <code>a</code> and <code>b</code> point to different memory locations:</p>

<pre><code>&gt;&gt;&gt; a = 12345
&gt;&gt;&gt; b = 12345
&gt;&gt;&gt; a is b
False
</code></pre>

<p>In the following, by contrast, they point to the same location:</p>

<pre><code>&gt;&gt;&gt; a = 1
&gt;&gt;&gt; b = 1
&gt;&gt;&gt; a is b
True
</code></pre></li>
</ol>

python python-2.7