Why I need the parameter when the call doesn't use it?

Ben Finney ben+python at benfinney.id.au
Mon Aug 29 08:15:34 CEST 2011


John Gordon <gordon at panix.com> writes:

> In <66a3f64c-d35e-40c7-be69-ddf708e37ba7 at glegroupsg2000goo.googlegroups.com> Niklas Rosencrantz <niklasro at gmail.com> writes:
>
> > What's the story of using these parameters that are called "self"?
>
> "self" is a reference to the class object, and it allows the method to
> access other methods and variables within the class.

No, ‘self’ (in an instance method, which is where it's normally used) is
bound to the instance object. The class object is a different thing.

-- 
 \         “Alternative explanations are always welcome in science, if |
  `\   they are better and explain more. Alternative explanations that |
_o__) explain nothing are not welcome.” —Victor J. Stenger, 2001-11-05 |
Ben Finney



More information about the Python-list mailing list