News for hackers. Stuff that matters.
Re:Wield Python's super() like a Jedi by guygurari on Thursday May 26, 2011 @01:38PM (#2588667)
It seems to me that code that uses super() in these creative ways will be very difficult to maintain. You need to understand the subtleties of the MRO just to find out which method is being called. Pitty the poor Python programmer who stumbles into such code without being aware that super() may not call the class's direct base.

I suppose similar criticism can be leveled against many other dynamic techniques, except that this one sacrifices more readability than I'm comfortable with.

Re:Wield Python's super() like a Jedi by jessedhillon on Thursday May 26, 2011 @02:31PM (#2588896)
super() supports arguments which allow you to specify which class's implementation to lookup, which is an explicit way to resolve ambiguities. Although well-designed multiple-inheritance should try to avoid those ambiguities in the first place -- a class shouldn't inherit from multiple bases with conflicting implementations of a method.

I think in a case like the one you describe, where the direct ancestor's implementation is circumvented to access a different ancestor's implementation, it should be done by calling

  super(Ancestor).someMethod()
That should improve understanding.
Re:Wield Python's super() like a Jedi by Peristarkawan on Thursday May 26, 2011 @02:35PM (#2588908)
I disagree, that's extremely fragile. It might work for the particular class you are implementing. However, it might cause subclasses of that class to break, since those subclasses will have a different MRO than the current class, and you could end up skipping more of the MRO than you intended.