Attack a sacred Python Cow
paul at boddie.org.uk
Sat Jul 26 00:32:44 CEST 2008
On 25 Jul, 22:37, Terry Reedy <tjre... at udel.edu> wrote:
> Kay Schluehr wrote:
> > This isn't the problem Jordan tries to address. It's really just about
> > `self` in the argument signature of f, not about its omission in the
> > body.
> That is not at all how I read him, so I will let him respond if he
> wishes. The main problem moving a function from module scope to class
> scope is prefixing the proper variables. Adding a param name, whether
> 'self', 's', 'this', or whatever, is trivial and hardly worth the ink.
He wrote the following of relevance:
"I added some classes to code that had previously just been functions,
and you know what I did - or rather, forgot to do? Put in the 'self'.
In front of some of the variable accesses, but more noticably, at the
start of *every single method argument list.*"
And rounding off with this on the subject:
"The problem is that the explicit requirement to have self at the
of every method is something that should be shipped off to the
I guess the desire is to have Java-like behaviour: when defining a
method, which must typically be done in the class definition in Java
(unless they've enhanced that area in the past few years), you never
write a "this" parameter in the method signature, but you are free to
qualify instance attribute accesses with "this". Personally, I liked
the Modula-3-inspired requirement for "self" in Python, but I can see
how a reminder of what it is in every method signature (defined within
a class) might be regarded as overly explicit.
More information about the Python-list