should "self" be changed?

Tim Chase python.list at tim.thechases.com
Tue May 26 17:10:42 EDT 2015


On 2015-05-26 21:45, Mark Lawrence wrote:
>> class MyClass(object):
>>     def __init__(ስ):
>>         ስ.dummy = None
> 
> Apart from breaking all the tools that rely on "self" being spelt
> "self" this looks like an excellent idea.

Though to be fair, they *are* broken tools if they rely on "self"
since there's nothing in the Python specs that require that.  It's
just a convention[1].

-tkc


[1]
https://docs.python.org/2/tutorial/classes.html#random-remarks
"""
Often, the first argument of a method is called self. This is nothing
more than a convention: the name self has absolutely no special
meaning to Python. Note, however, that by not following the
convention your code may be less readable to other Python
programmers, and it is also conceivable that a class browser program
might be written that relies upon such a convention.
"""
It does give fair warning, but I'd consider that a warning to authors
of "class browser program[s]" as much as to developers.






More information about the Python-list mailing list