This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients Retro, docs@python, r.david.murray
Date 2011-02-25.13:23:28
SpamBayes Score 3.6186228e-07
Marked as misclassified No
Message-id <1298640208.93.0.850735850736.issue11318@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2011-02-25 13:23:29r.david.murraysetrecipients: + r.david.murray, Retro, docs@python
2011-02-25 13:23:28r.david.murraysetmessageid: <1298640208.93.0.850735850736.issue11318@psf.upfronthosting.co.za>
2011-02-25 13:23:28r.david.murraylinkissue11318 messages
2011-02-25 13:23:28r.david.murraycreate