how to give an object as argument for a method

Marco Herrn herrn at gmx.net
Thu Mar 7 18:50:52 EST 2002


On Thu, Mar 07, 2002 at 03:46:59PM +0000, Grant Edwards wrote:
> 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.

Hmm, ok. All you say seems right to me. But what is a bit strange is,
that I explicitly have to implement 'self', but don't give it as argument.
If a have a method with the defininion 'f(self)' I call this method only
with 'f()'. So the declaration doesn't look the same like the call.

So you think it will stay this way, that one has to implement it for
himself. That's ok. I can live with that. But I don't see any
disadvantage, when changing the language so that a 'self' statement is
always available.

Bye
Marco

-- 
Ein fester Satz an Vorurteilen ist ausgesprochen praktisch. Er
erspart einem das Nachdenken.

--
Marco Herrn             herrn at gmx.net
(GnuPG/PGP-signed and crypted mail preferred)
Key ID: 0x94620736




More information about the Python-list mailing list