Guido's new method definition idea
Brian Blais
bblais at bryant.edu
Sun Dec 7 15:27:08 EST 2008
On Dec 5, 2008, at 21:21 , Daniel Fetchinson wrote:
> The proposal is to allow this:
>
> class C:
> def self.method( arg ):
> self.value = arg
> return self.value
>
> instead of this:
>
> class C:
> def method( self, arg ):
> self.value = arg
> return self.value
>
I have never understood the objection to the explicit self. As far
as I can tell it just stems from laziness, and perhaps (more
legitimately) from an unclear error message about arguments. When I
was a python newbie, a short while ago, I would have to look twice at
the number of arguments in the error, but quickly learned what this
meant. Forgetting self, which I still do, makes me do a face slap,
but I always felt that it is *my* problem, and I still do. It is far
clearer what is going on with the explicit self.
Even if I were lazy, and didn't want to type it, it seems as if the
proposal saves me nothing there....so why have it? It is also
confusing, because when you're reading the code, "self" is not
defined at the time, so it looks weird to have self.method pop up.
Allowing both would be *ultra* confusing. I teach python to a lot of
students who are new programmers, and for them to see two different
forms for the same thing would be very bad, and I see absolutely no
benefit, even to experienced programmers. What problem is it
supposed to solve?
+1 on changing the error text, however, perhaps even with a
suggestion..."possibly missing 'self' argument."
bb
--
Brian Blais
bblais at bryant.edu
http://web.bryant.edu/~bblais
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081207/e5cbff3d/attachment-0001.html>
More information about the Python-list
mailing list