should "self" be changed?

random832 at fastmail.us random832 at fastmail.us
Tue May 26 14:11:42 EDT 2015


On Tue, May 26, 2015, at 12:57, Laura Creighton wrote:
> Guido did.  :)
> http://neopythonic.blogspot.se/2008/10/why-explicit-self-has-to-stay.html

It's worth noting that the "dynamically modify a class" argument (and to
some extent the decorator argument) misses Javascript's solution - _any_
function may refer to "this" (which is not in the argument list), which
will be the global scope object (the browser window for browser-hosted
javascript - presumably the current module for a hypothetical equivalent
python feature, though it might be more prudent to simply make it None.)
if the function is called without an object reference. Of course,
Javascript also lacks bound methods, which makes it much more likely to
happen by accident.

I can't really think of anything that you can do with decorators,
either, in the current model, that you _couldn't_ do in a JS-alike
function call model... but I doubt it would be possible to implement
backwards-compatibly.

In principle, if you added a class keyword (hey, technically, isn't
there one already?) you wouldn't need decorators at all for the
staticmethod/classmethod/instance method case.



More information about the Python-list mailing list