Is there a consensus on how to check a polymorphic instance?
Carlos Ribeiro
carribeiro at gmail.com
Wed Nov 24 04:40:57 EST 2004
On 23 Nov 2004 19:58:31 -0800, Mike Meng <meng.yan at gmail.com> wrote:
> > I come from a very conservative background in software development
> > and strong checks are deeply rooted in my mind.
>
> So do I, Dan.
>
> I just can't imagine a `wild' object whose interface is valid can
> truely do the right things. While in fact, when I typing this word, I
> realize we can't ensure the internal protocol will be obeyed even when
> the object IS-A base class instance.
>
> Maybe it's time to rethink.
I understand, and I found myself using isinstance more often that I
would like to admit. Being trained in OO Pascal & Delphi it comes as
no surprise...
> It seems to me the virtue of dynamic langauge is, if it looks like a
> cat, it's a cat. But the problem is still there: how do you know what
> it looks like before you treat it as a cat? isinstance(), , as Steve
> state, is too rigid.
Time for adapt(), I think...
--
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com
More information about the Python-list
mailing list