[Python-3000] Removing 'self' from method definitions

Phillip J. Eby pje at telecommunity.com
Thu Apr 13 23:19:06 CEST 2006


At 12:58 PM 4/13/2006 -0700, Michael Chermside <mcherm at mcherm.com> wrote:
>To be abundantly specific, the proposal is that if the next two tokens
>after a "def" were "self" and "." then the result of compiling such
>code would be exactly the same as if they were not present but "self"
>and "," were inserted immediately after the opening parenthesis.
>Whether to allow any identifier or only the particular identifier
>"self" is an interesting question that I would leave for Guido.
>
>Personally, I favor doing this. I think that making declarations look
>similar to invocations is very useful.

You could make them look even closer if it worked like this:

     def .aMethod(arg1, arg2):
         return .otherMethod(arg1*2+arg2)

In other words, 'self' here is uniformly replaced by an empty string.  :)

Interestingly, I believe this syntax could get everybody off our backs 
about explicit self, as although it is still explicit, it's in an implicit 
way.  :)

Of course, for this to really work properly, you would have to be able to 
use a bare '.' to mean the hidden argument, for cases like "getattr(.,foo)" 
and ".[27]".



More information about the Python-3000 mailing list