Why the 'self' argument?

John Roth newsgroups at jhrothjr.com
Sat Sep 6 14:47:52 EDT 2003


"Harri Pesonen" <fuerte at sci.fi> wrote in message
news:Ucp6b.3992$ZB4.3874 at reader1.news.jippii.net...
> Jonathan Aquino wrote:
> > Two reasons I cringe when I see self as the first parameter of method
> > declarations (i.e. "def methodname(self, ...)" (I don't mind self in
> > the method body)):
> >
> > 1) I abhor redundancy. My first impression on seeing self as the first
> > parameter of all method declarations is that it seems redundant -- it
> > probably isn't technically, but it looks redundant: (self, (self,
> > (self, (self, ...
> >
> > 2) The number of parameters in the method call is one less than the
> > number of parameters in the method declaration. I'm annoyed when I see
> > this because I want the rules of the language to be obvious (in this
> > case, a one-to-one mapping). I would be embarassed to have to explain
> > this to a beginning programmer.
> >
> > (I do like how Python indenting indicates blocks, however)
>
> I agree, it's not logical. I'm learning Python at the moment, and like
> it very much. This "self" thing seems to be the only odd feature, it
> feels like the whole class feature was added later. The Quick Python
> book says that Python was designed to be object oriented from the ground
> up. Is it true?

I'm not sure; someone who knows the history back to the beginning
would have to say. However, there's a difference between "from the
ground up," which is certainly true, and "from the beginning" which
may or may not be true.

John Roth

>
> Harri
>






More information about the Python-list mailing list