September 2nd, 2003, 10:15 PM
Newbie questoins :/
i'm reading this code
there is alot of
there are classes too
how does the self thing work in so many classes :/
September 3rd, 2003, 06:36 AM
'self' is just an explicit reference to the object in which 'self' is bound.
Every member method in Python must include in its list of parameters as first formal parameter a name to which Python will bind a reference to the object. You could use the name 'this' or 'lolita' or any valid name, but by consensus, and by the word of GvR, the name 'self' is most often used.
'self' is just like 'this' in Java, except for the fact that you explicitly include it as first of your formal parameters in any member method, whereas in Java, the parameter is there, and the reference is passed, but everything is implicit.
For more information, look at Chapter 9. Classes in the Python Tutorial, or, for a more terse explanation, you could look at §4.21 What is self? in the Python FAQ.
Last edited by percivall; September 3rd, 2003 at 06:41 AM.