Newbie question: what's with "self"?
Farshid Lashkari
no at spam.com
Tue Aug 8 12:48:57 EDT 2006
donkeyboy wrote:
> This is probably a really basic question, but anyway ...
>
> I'm new to both Python and OO programming. From looking at a number of
> code examples, the word "self" is used a lot when referring to classes.
> As such, what does "self" mean and/or do? I've read things that say
> it's a naming convention, but no-one has really spelt it out (in idiot
> form!) in a way I can understand.
>
> Any help you can provide would be great: at the moment, when code
> doesn't work as expected, I'm randomly sprinkling "self"s in all over
> the place to see if that helps, but without much of an idea of what it
> really achieves.
>
> Thanks in advance!!
>
Hi,
Take a look at the following FAQ on the python homepage:
http://www.python.org/infogami-faq/general/why-must-self-be-used-explicitly-in-method-definitions-and-calls/
-Farshid
More information about the Python-list
mailing list