Programmer's Wiki
Advertisement
Forums: Index > Watercooler > In programming what does it mean when a function uses a variable named "self"?



a question posted on wikiaanswers.

In python the self variable is a convention. you could actually call it anything you like. However any other programmers working on the code would then have to figure it out.

the variable gets set to a reference to the instance you are calling it on. That way you have access to it's variables and other methods. --Drawde83 20:19, February 11, 2010 (UTC)

In PHP, `this' works like Python's `self' (except it can't be renamed) and `self' is the class of `this'. --Jesdisciple (talk) 02:23, June 12, 2010 (UTC)
Advertisement