Mailing List Archive

Does the first argument of a method *has to be* self?
Hello,

I never saw code where the first argument of a method wasn't self. Is it
in theory possible?

groeten,
Gerrit.

--
The Dutch Linuxgames homepage: http://linuxgames.nl.linux.org
Personal homepage: http://www.nl.linux.org/~gerrit/

Discoverb is a python program (in several languages) which tests the words you
learned by asking it. Homepage: http://www.nl.linux.org/~gerrit/discoverb/
Does the first argument of a method *has to be* self? [ In reply to ]
On Wed, 30 Jun 1999 22:21:21 +0200, Gerrit Holl wrote:
>Hello,

>I never saw code where the first argument of a method wasn't self. Is it
>in theory possible?

It's always self, although you're free to call it anything you want.

>Gerrit.

--
-William "Billy" Tanksley
Does the first argument of a method *has to be* self? [ In reply to ]
From: wtanksle@dolphin.openprojects.net (William Tanksley)

On Wed, 30 Jun 1999 22:21:21 +0200, Gerrit Holl wrote:
>Hello,

>I never saw code where the first argument of a method wasn't self. Is it
>in theory possible?

It's always self, although you're free to call it anything you want.

>Gerrit.

--
-William "Billy" Tanksley
Does the first argument of a method *has to be* self? [ In reply to ]
In article <19990630222121.A1121@optiplex.palga.uucp>,
Gerrit Holl <gerrit.holl@pobox.com> wrote:
>
>I never saw code where the first argument of a method wasn't self. Is it
>in theory possible?

Yes and no. The first argument always *is* self, but it can be named
something else. For example:

class foo :
def bar(s):
s.bar() # recursive call
--
--- Aahz (@netcom.com)

Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het
Does the first argument of a method *has to be* self? [ In reply to ]
Gerrit Holl wrote:
>
> Hello,
>
> I never saw code where the first argument of a method wasn't self. Is it
> in theory possible?

As one thinks about it, the first argument being self (the instance)
is a handy feature. Why would you want to put it somewhere else?

As the documentation states "self" is just some conventional name.
Renaming self into something else is probably a bad idea as it
will make your code less readable for others (and YOU as time passes!).

Experience shows that having conventions is a powerful way to
make life and code maintenance easier.

Kind regards,
===================================================================
Johan Wouters === Easics ===
ASIC Designer === System-on-Chip design services ===
Tel: +32-16-395 616 ===================================
Fax: +32-16-395 619 Interleuvenlaan 86, B-3001 Leuven, BELGIUM
mailto:johanw@easics.be http://www.easics.com
Does the first argument of a method *has to be* self? [ In reply to ]
From: Johan Wouters <johanw@easics.be>

Gerrit Holl wrote:
>
> Hello,
>
> I never saw code where the first argument of a method wasn't self. Is it
> in theory possible?

As one thinks about it, the first argument being self (the instance)
is a handy feature. Why would you want to put it somewhere else?

As the documentation states "self" is just some conventional name.
Renaming self into something else is probably a bad idea as it
will make your code less readable for others (and YOU as time passes!).

Experience shows that having conventions is a powerful way to
make life and code maintenance easier.

Kind regards,
===================================================================
Johan Wouters === Easics ===
ASIC Designer === System-on-Chip design services ===
Tel: +32-16-395 616 ===================================
Fax: +32-16-395 619 Interleuvenlaan 86, B-3001 Leuven, BELGIUM
mailto:johanw@easics.be http://www.easics.com