reason/history of self

rihad rihad at mail.ru
Wed Jan 16 12:12:42 EST 2002


On Wed, 16 Jan 2002 11:55:05 +0100, gabor farkas <xlat at pobox.sk>
wrote:

>hi,
>
>
>i'm sure this was discussed before, but i cant find it..
>
It's in the faq :)

>
>why do i have to write self as the first parameter of a method in the 
>method-definition?
>
I've just read the faq entry 
6.7. Why must 'self' be declared and used explicitly in method
definitions and calls?

And, quite frankly, have to agree with GvR in that `C++ does this
through declarations, but Python doesn't have declarations and it
would be a pity having to introduce them just for this purpose.' 

(read the whole thing)

Indeed, PHP, for example, also uses the `this->field_name' notion
except that `this' is predefined theret. Anyway, I don't see much
trouble in explicitly referring to instance, it just takes some time
getting used to.




More information about the Python-list mailing list