should "self" be changed?

Laurent Pointal laurent.pointal at free.fr
Tue May 26 12:59:47 EDT 2015


zipher wrote:

> Would it be prudent to rid the long-standing "argument" (pun unintended)
> about self and the ulterior spellings of it, by changing it into a symbol
> rather than a name?
> 
> Something like:
> 
> class MyClass(object):
> 
>     def __init__(@):
>         @.dummy = None

Just seeing the Python3.5 announce with @ used as matrix multiplication 
operator ;-)

> OR, even better, getting *rid of it* in the parameter list, so it stops
> confusing people about how many parameters a method needs, and transform
> it into a true *operator*.

Self is not an operator, its the target object as first parameter. And with 
Python you can call some methods directly using theclass.themethod(objet, 
param1, param2).

> class MyClass(object):
> 
>     def __init__(): #takes no arguments!
>         @.dummy = None  #the @ invokes the class object's dictionary
> 
> That would seem to be a nice solution to the problem, really.  It doesn't
> become PERLish because you've made it into a genuine operator -- "self"
> was always a non-variable that looked like a variable and hence created an
> itch that couldn't be scratched.

«Explicit is better than implicit»

I think that googling for that idea you will find other people already 
proposing it (I've seen propositions to directly remove part before the dot 
like this: .dummy = None). Just read it.

> Anyone else have any thoughts?

IMHO Zero chance that it be adopted.

A+
Laurent.




More information about the Python-list mailing list