Learning OOP...

Alex Martelli aleaxit at yahoo.com
Mon Jun 11 12:21:35 EDT 2001


"Rainer Deyke" <root at rainerdeyke.com> wrote in message
news:535V6.147522$oc7.8844949 at news2.rdc2.tx.home.com...
> "Alex Martelli" <aleaxit at yahoo.com> wrote in message
> news:mailman.992248937.25086.python-list at python.org...
> >   The
> > problem is the entanglement, NOT inheritance, which, in Python,
> > is just a neat and powerful reuse-mechanism -- no more, no less.
>
> Counterexample: the exception hierarchy.

True, 'except' (for the current class-based exceptions) is
defined to work on the basis of inheritance.  You can, if you
wish, implement similar "typecheck-like" mechanisms yourself
by using the built-in isinstance function (but I would not
recommend it as a general Python programming practice -- it's
just a notch above type(foo)==type(bar) in terms of annoyance;
however, if I had to design from scratch an exception catching
mechanism for Python WITHOUT benefit of PEP's 245 and 246, I
cannot think of anything better than the inheritance-based kludge).


Alex






More information about the Python-list mailing list