how to give an object as argument for a method

Grant Edwards grante at visi.com
Thu Mar 7 10:46:59 EST 2002


In article <mailman.1015496653.15042.python-list at python.org>, Marco Herrn wrote:

> Is there a reason why this is just a convention?

Because it seems to work well enough that way.

> It seems (because it is such a _strong_ convention) that this
> should be a real feature of the language. I mean that there
> could be a reserved word "self" which is there all the time, so
> that one doesn't hast to do this himself.

It would make the language and the parser more complex.
Extra cost must be justified by some corresponding gain.  It
would also make it less obvious what "self" is if the first
parameter to a method was hidden from the user.

If a function expects a parameter, then it should show up in
the function definition.  Methods are just functions whose
first parameter is expected to be an object reference.

-- 
Grant Edwards                   grante             Yow!  Did we bring enough
                                  at               BEEF JERKY?
                               visi.com            



More information about the Python-list mailing list