Message52529
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).
|
|
Date |
User |
Action |
Args |
2007-08-23 15:58:15 | admin | link | issue1708353 messages |
2007-08-23 15:58:15 | admin | create | |
|