class super method

Ed Leafe ed at leafe.com
Tue Apr 1 21:44:45 EDT 2008


On Apr 1, 2008, at 6:10 PM, Steve Holden wrote:

> Ed is a good enough designer to avoid the corner cases. Strangely  
> enough
> the one place where I have ended up making significant use of super()
> was in providing mixins for wxPython interface classes!

	Thanks much for the compliment. Yes, wrapping the disparate and  
confusing wxPython classes to have a consistent interface is where we  
also make the most use of super(), but our database wrappers also  
provide consistent functionality to all the dbapi cursors, no matter  
what the backend database may be.

	The only reason this works is that we are working with a single known  
class interface; we control all our own mixin class designs. With the  
wxPython stuff, each class has a well-defined set of methods and  
method signatures, and with the database stuff, we only mixin with the  
dbapi-standard methods, and avoid hooking into module-specific  
enhancements.

	My point in these postings is that working with multiple inheritance  
is fraught with potential pitfalls; super() doesn't create these  
pitfalls, although it can make it easier to fall into them. If you try  
to create a PotBelliedElephant class by using MI with a PotBelliedPig  
class and an Elephant class, well, you *should* crash and burn,  
whether you use super() or not.

http://en.wikipedia.org/wiki/An_Elephant_Makes_Love_to_a_Pig

-- Ed Leafe






More information about the Python-list mailing list