[Python-3000] Removing 'self' from method definitions

Ian Bicking ianb at colorstudy.com
Thu Apr 13 21:17:39 CEST 2006


Ian Bicking wrote:
> I propose: 'self' and 'cls' implicit arguments.  Their presence as the 
> first argument to a function or method will be ignored, for backward 
> compatibility.

It occurs to me that some of the problems with doing this involve the 
fact that you can't know how if a function is a function or a method; 
adding an implicit self argument that is injected only when the function 
is called causes some potential problems.

Maybe another way to implement this would be for the metaclass (type) to 
change functions when they were added to the class.  Then classes 
wouldn't just contain functions with a wrapper applied when an attribute 
is accessed; instead they would flip a switch on the function that turns 
it into a method.  This seems like it removes some of the abiguity of an 
implicit argument.

This seems like it might be possible to implement in Python right now, 
so perhaps an experiment along those lines would be useful to consider 
the full extent of what such a change.

-- 
Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org


More information about the Python-3000 mailing list