R. David Murray <rdmur...@bitdance.com> added the comment:

Read a little further:

    Caution: within a method of C, an assignment like ``self.count = 42`` 
creates a new and unrelated instance named "count" in ``self``'s own dict.

That is, c.count refers to C.count right up until the point where c.count is 
assigned a value.  So, c.count = c.count + 1 will add one to the current value 
of C.count, and assign it to the *instance* variable c.count.  c.count at that 
point no longer refers to the *class* variable C.count.  Thus your change to 
the __init__ function would completely defeat the purpose of the example (which 
is to show how to use a *class* variable.

If you can suggest a concise wording that would have made this clearer to you, 
we can consider a doc patch.

----------
nosy: +r.david.murray
type:  -> behavior

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11318>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to