[Python-3000] Removing 'self' from method definitions (original) (raw)

Guido van Rossum guido at python.org
Fri Apr 14 14:16:03 CEST 2006


Michael Chermside wrote: > Ian Bicking writes: >> I propose that the self argument be removed from method definitions. > > This is not a new proposal. The fundamental problem is a perceived > mismatch between the argument list used for calling and the argument > list used in defining the method. Of the many times that it has been > proposed, the best syntax I have seen was as follows: > > def self.mymethod(arg1, arg2): > # body goes here

-1 to this version and to Ian's original proposal. You can save your breath, or write up a PEP with the goal of explaining why this proposal (which keeps coming back) is a bad idea -- such a PEP would be a good idea but it won't get the feature accepted.

Capsule argument Ian's original proposal: you're proposing to hide a fundamental truth in Python, that methods are "just" functions whose first argument can be supplied using syntactic sugar in the call (x.foo() instead of x.class.foo(x)).

And against the "def self.foo(x):" syntax: that's a lot of new syntax for no gain in readability. You just need to get your head around the fundamental truth (see above), just like you should get used to reading " ".join(list_of_strings).

-- --Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-3000 mailing list