[newbie] - what is self variable?

D-Man dsh8290 at rit.edu
Wed May 30 11:31:38 EDT 2001


On Wed, May 30, 2001 at 03:15:19PM +0000, Cervantes wrote:
| hello,
| 
| i've already written a few python scripts but am just learning oop. i notice
| many examples make use of a 'self' variable under __init__ , what does this
| referr to?
| 
| is it like a this pointer?

Yes.  Instead of being passed to the function implicitly (C++, Java)
it is passed explicitly as the first argument.  It is conventionally
called 'self', though it can be called anything you want to call it
(including 'this').

-D





More information about the Python-list mailing list