Different Behavior while calling Attributes from Class and Instance Variables
<p>I defined such simple class as below:</p>

<pre><code>&gt;&gt;&gt; class myclass(object):
    name = "google"
</code></pre>

<p>And I am creating an instance to call name attribute </p>

<pre><code>&gt;&gt;&gt; a = myclass()
&gt;&gt;&gt; a.name
'google'
</code></pre>

<p>and also calling it directly from the class itself. </p>

<pre><code>&gt;&gt;&gt; myclass.name
'google'
</code></pre>

<p>So far (as I am having background with C# and Java) I will call <code>myclass.name</code> static invocation and calling static members from instances are fine.</p>

<p><strong>But</strong> what I am observing is till I set <code>a.name</code> with another value, changing <code>myclass.name</code> is also affecting <code>a.name</code>. Once I set <code>a.name</code>, changing <code>myclass.name</code> doesn't affect the <code>a.name</code> any more and they begin to have different values.</p>

<p>You can see the whole experiment below:</p>

<pre><code>&gt;&gt;&gt; class myclass(object):
    name = "google"


&gt;&gt;&gt; myclass.name
'google'
&gt;&gt;&gt; a = myclass()
&gt;&gt;&gt; a.name
'google'
&gt;&gt;&gt; myclass.name = "yahoo"
&gt;&gt;&gt; a.name
'yahoo'
&gt;&gt;&gt; myclass.name = "hello world"
&gt;&gt;&gt; a.name
'hello world'
&gt;&gt;&gt; myclass.name
'hello world'
&gt;&gt;&gt; myclass.name = "another trick"
&gt;&gt;&gt; myclass.name
'another trick'
&gt;&gt;&gt; a.name
'another trick'
&gt;&gt;&gt; a.name = "I changed the value of a"
&gt;&gt;&gt; a.name
'I changed the value of a'
&gt;&gt;&gt; myclass.name
'another trick'
&gt;&gt;&gt; myclass.name = "changed again"
&gt;&gt;&gt; a.name
'I changed the value of a'
</code></pre>

<p>I would like someone to explain the reason behind this behavior.</p>

<p>Thanks.</p>
