[Tutor] class questions

Payal payal-python at scriptkitchen.com
Sat Jun 26 19:05:16 CEST 2010

Thanks a lot for the quick answer. Still some doubts below.

On Sat, Jun 26, 2010 at 11:07:17PM +1000, Steven D'Aprano wrote:
> The old MRO (Method Resolution Order) is broken for classes using 
> multiple inheritance with a diamond shape inheritance diagram. Not a 
> little bit broken, but horribly, horribly broken.
> If you have something like this class hierarchy:
> (only with actual methods, of course) then inheritance with old-style 
> classes cannot work correctly in some circumstances. Fortunately this 

Can you give any simple example where this simple mro will work
incorrectly? i read,
butdid not get where mro will fail (ofcourse if python implemented it

> is rare for old-style classes. But for new-style classes, *all* multiple 
> inheritance is diamond-shaped, because all classes inherit back to 
> object at the top of the diagram:

still not getting , how do the new style classes solve the problem (if
there was any).

> Python doesn't have a special "abstract class" type, but it is easy to 
> make one with just two lines of boilerplate:

Sorry, I am not getting it. I get,
NameError: global name 'Abstract' is not defined
Was that a working code? (cos' I do not know what you mean by

> class DomainError(ValueError):
>     """Used for mathematics domain errors."""
>     pass

Can we say that our own exception classes have only maybe a doc-string
and pass, nothing more?

Thanks a lot again.
With warm regards,

More information about the Tutor mailing list