[Python-ideas] Explicit self argument, implicit super argument
Neil Toronto
ntoronto at cs.byu.edu
Tue Nov 20 03:37:09 CET 2007
Luke Stebbing wrote:
> On 11/19/07, Arnaud Delobelle <arno at marooned.org.uk> wrote:
>> Self being explicit makes it less selfish :)
>> To illustrate, I like that you can do:
>>
>> class Foo(str):
>> def mybar(self):
>> class Bar(str):
>> def madeby(me):
>> return "I am %s and I was made by %s" % (me, self)
>> return Bar
>>
>
> How about:
>
> class Foo(str):
> def mybar():
> outer = self
> class Bar(str):
> def madeby():
> return "I am %s and I was made by %s" % (self, outer)
> return Bar
Good point. I actually like this better, since it forces the outer scope
self to have a different name, removing a source of confusion. Back down
to two uncommon use cases so far, then.
Neil
More information about the Python-ideas
mailing list