mk a écrit : > Bruno Desthuilliers wrote: >> mk a écrit : >>> P.S. Method resolution order in Python makes me want to kill small >>> kittens. >> >> mro is only a "problem" when using MI. > > Oh sure! And I have the impression that multiple inheritance is not used > all that often. What (some) Python code I've read in open source > projects typically uses single inheritance.
Single inheritance does indeed cover most of the needs - and FWIW, even single inheritance is not used as much in Python as in some other more mainstream OOPLs. This comes partly from duck typing - inheritance is only used for implementation inheritance, not for type-based polymorphic dispatch -, and partly from Python's support for composition/delegation (thru __getattr__). Also - as you noticed - single inheritance is easier to grasp, and Python's philosophy really values simplicity, readability, maintainability, and coder's mental health !-) > Nevertheless MI is there in Python, might be useful in some cases and > Guido put it there for some reason, Indeed. As with most Python's "advanced" features, it's there so you can use it when appropriate. > so Citizens Aspiring To Become > Pythonistas like me work to learn it. FWIW, I very rarely had to use it myself in almost 10 years of Python programming - main exceptions being Zope2 stuff (which is IMHO highly unpythonic) and a couple mixin classes here and there. -- http://mail.python.org/mailman/listinfo/python-list
