
September 3rd, 2003, 06:36 AM
|
|
Contributing User
|
|
Join Date: Jul 2003
Posts: 133
Time spent in forums: < 1 sec
Reputation Power: 6
|
|
'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.
|