[Python-Dev] Evil isinstance()

David Abrahams David Abrahams" <david.abrahams@rcn.com
Sun, 31 Mar 2002 19:54:51 -0500

----- Original Message -----
From: "Samuele Pedroni" <pedroni@inf.ethz.ch>

> > Maybe you can summarize it again using a different vocabulary?  I
> > that PEP very hard to read, but I recall liking your informal
> > explanation of it.  Unfortunately I don't recall enough of that
> > explanation to go ahead and approve the PEP (I have no idea what
> > effect that would have).
> It's a tool, IMHO what is missing is a common dictionary of protocols
> and idioms,

Agreed, establishing some useful protocols would really help, especially
if these protocols correspond to objects provided by the core language
and standard library. Warning: we might feel compelled to try to define
what constitutes a Sequence, Number, or Mapping (not a bad idea anyway,

> Alex says we don't need that, just let people
> have the tool and be inspired by other frameworks.

I don't think we'd need to try to be exhaustive, but IMO establishing
some examples of good practice is important. It's also important to
define the protocols that everyone will define over and over again if we
don't do it (ahem: Sequence, Number, Mapping...)

> E.g. how should one spell the example test:
> adapt(thearg,str)
> # but then what about unicode and should str have
> #  an __adapt__ ?
> or
> adapt(thearg,StringLike)
> but then should every one define his StringLike,
> or should the std lib define one, should StringLike
> __conform__ use the +'' trick or not.
> Further the PEP suggests that a global
> registry for 3rd part adaptations would be useful
> (and give more degree-of-freedom to cope
> with the above issues)
> but it does not specify it, it specify just a global
> __import__-like hook for adaptation,
> but __import__ problems suggest that is not
> a valid solution...

>From my experience with the traits idiom in C++, I guess that some
non-intrusive way to associate protocols and types will be very

FWIW, I'm interested in this partly as an avenue to multimethod support
for Python.