← Back to team overview

dolfin team mailing list archive

Re: Strange error from function.py

 

On Wed, Dec 3, 2008 at 9:56 AM, Martin Sandve Alnæs <martinal@xxxxxxxxx> wrote:
> 2008/12/3 Johan Hake <hake@xxxxxxxxx>:
>> Btw, is there any special function that defines a class's isinstance protocol?
>> If there was we could define our own __isinstancecheck__?
>
> You're insane. I'm happy to say there is no such thing.
> (I think Python 3 adds some way of saying
> "MyClass supports this protocol" without inheritance)

Turns out you're not alone... Python 2.6 has exactly this feature ;-)
http://www.python.org/dev/peps/pep-3119/#overloading-isinstance-and-issubclass

(But that can never be a workaround for missing C++ inheritance).

Martin


References