Boštjan Mejak bostjan.me...@gmail.com added the comment:
Understood. Now I get it. If you create an instance c of the class C (so c
= C() ) and try to get the variable count from that class, then c.count is
the same reference as C.count.
Please make that clearer in the FAQ by saying If you
New submission from Boštjan Mejak bostjan.me...@gmail.com:
I have found a possible typo in an example code of Python 3.2. It's located on
page 32 in the PDF version of the FAQ document. The code is:
class C:
count = 0 # number of times C.__init__ called
def __init__(self):
C.count =
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
R. David Murray rdmur...@bitdance.com added the comment:
Hmm. Rereading your message, is seems like you just didn't understand the
statement c.count refers to C.count for any That is a statement about
how the language behaves. If there is not yet an instance variable 'count',
but a
Boštjan Mejak bostjan.me...@gmail.com added the comment:
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.
More clear is to say *Caution: within a method of class C, an assignment
like ``self.count
Boštjan Mejak bostjan.me...@gmail.com added the comment:
So you're saying that if a class' name is C, then c.count is the same as
C.count? I thought Python is case-sensitive. You know: c (small letter c) is
not equal to C (big letter C) in Python. I don't understand what you mean by
c.count
Georg Brandl ge...@python.org added the comment:
Now it's clear that David is right -- what c refers to is defined in this
very sentence.
--
nosy: +georg.brandl
resolution: - invalid
status: open - closed
___
Python tracker rep...@bugs.python.org
Boštjan Mejak bostjan.me...@gmail.com added the comment:
I don't understand it. My bad. Please explain to me exactly what c refers
to.
--
Added file: http://bugs.python.org/file20891/unnamed
___
Python tracker rep...@bugs.python.org
R. David Murray rdmur...@bitdance.com added the comment:
Please consult the python tutor's list, the bug tracker is not the place to get
introductory help with Python.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11318
Boštjan Mejak bostjan.me...@gmail.com added the comment:
How awful! A little pointer to the tutorial where this is explained would be
also quite smashing.
--
Added file: http://bugs.python.org/file20893/unnamed
___
Python tracker
Boštjan Mejak bostjan.me...@gmail.com added the comment:
c.count also refers to C.count Where in the code is c.count? Please
explain this for the sake of really closing this issue.
--
Added file: http://bugs.python.org/file20896/unnamed
___
Python
Changes by Éric Araujo mer...@netwok.org:
Removed file: http://bugs.python.org/file20888/unnamed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11318
___
Changes by Éric Araujo mer...@netwok.org:
Removed file: http://bugs.python.org/file20890/unnamed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11318
___
Changes by Éric Araujo mer...@netwok.org:
Removed file: http://bugs.python.org/file20891/unnamed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11318
___
Changes by Éric Araujo mer...@netwok.org:
Removed file: http://bugs.python.org/file20893/unnamed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11318
___
Changes by Éric Araujo mer...@netwok.org:
Removed file: http://bugs.python.org/file20896/unnamed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11318
___
Éric Araujo mer...@netwok.org added the comment:
If the tutorial is not clear enough, try for example
http://diveintopython.org/object_oriented_framework/class_attributes.html.
Please ask on a suitable venue if you don’t understand instead of this tracker.
(Please don’t send HTML email to
Boštjan Mejak bostjan.me...@gmail.com added the comment:
Eric, the thing I don't understand is why is there that c.count thing. How is
it possible for c.count to be the same reference as C.count? Where is c
defined?
--
___
Python tracker
Éric Araujo mer...@netwok.org added the comment:
What this part means is: “If you create an instance of C named c, and get
c.count, it will get the attribute count defined on C.” IOW: You can get a
class variable from any instance.
In the example, the code in __init__ cannot assign to
Changes by Éric Araujo mer...@netwok.org:
--
assignee: docs@python -
nosy: -docs@python, eric.araujo
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11318
___
20 matches
Mail list logo