Re: The need to put "self" in every method
- From: roy@xxxxxxxxx (Roy Smith)
- Date: 31 May 2005 12:52:20 -0400
Fernando M. <fernandomirandamuro@xxxxxxxxx> wrote:
>i was just wondering about the need to put "self" as the first
>parameter in every method a class has because, if it's always needed,
>why the obligation to write it? couldn't it be implicit?
Didn't this exact question get asked just a few days ago?
Anyway, the short answer is:
1) Yes, it's always needed.
2) It's part of the Python design philosophy that "explicit is better
than implicit".
Note that in languages like C++ where using "this->" is optional,
people invent their own conventions for keeping local and instance
variables distinct, like prepending m_ to member names (except that
different people do it different ways, so it's more confusing).
.
- References:
- The need to put "self" in every method
- From: Fernando M.
- The need to put "self" in every method
- Prev by Date: Re: Running twisted http server - "Method Not Allowed" error
- Next by Date: Re: COM+, Javascript and Python
- Previous by thread: Re: The need to put "self" in every method
- Next by thread: Dr. Dobb's Python-URL! - weekly Python news and links (May 31)
- Index(es):
Relevant Pages
|