Author gvanrossum
Recipients
Date 2007-04-26.20:16:58
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
I came up with a fairly simple way to overload isinstance() and issubclass().  The class that is the second argument can define a (class) method named __instancecheck__ or __subclasscheck__ which, if present, will be called *instead* of the normal approach.

The names are different to remind users that the calling convention is the opposite -- isinstance(x, C) maps to C.__instancecheck__(x).
History
Date User Action Args
2007-08-23 15:58:15adminlinkissue1708353 messages
2007-08-23 15:58:15admincreate