Self Nanny

bjorn bjorn at roguewave.com
Mon Mar 6 15:20:35 EST 2000


Paul Prescod wrote:

> I have never seen correct Python code where the first argument to a
> method was not named "self". Therefore I think that the flexibility of
> allowing it to be named "spam" is more trouble than it is worth. Python
> should just require "self" be named "self".

Until we get proper lexical scoping, in which case an explicit self
argument is not only needed, but needs to have the opportunity to be
different from the enclosing method's self:

    class Outer:
        def foo(self):
            self.x = 1
            class Inner:
                def bar(me):
                    me.x = 2
                    return me.x + self.x
            return Inner

of-course-we-could-always-use-the-Java-hack'ly y'rs
-- bjorn






More information about the Python-list mailing list