On Mon, 19 Sep 2005, Adam Monsen wrote: > Is there anything wrong with using something like super(type(self), > self).f() to avoid having to hardcode a type?
What happens when that method gets called by an overriding method in a derived class? > For example: > > class A(object): > def f(self): > print "in A.f()" > > class B(A): > def f(self): > super(type(self), self).f() > > obj = A() > obj.f() # prints "in A.f()" Continuing your example: class C(B): def f(self): super(type(self), self).f() obj = C() obj.f() Think about what's going to happen. Then try it! > By "wrong" I mean, is there any reason why this is just a Bad Idea? That rather depends if the behaviour i demonstrate above is useful to you. :) > Seems helpful to me, if I change the name of the 'B' class, I don't have > to change super() calls as well. It would indeed be very useful. tom -- buy plastic owl -- http://mail.python.org/mailman/listinfo/python-list