Message52529
| 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:15 | admin | link | issue1708353 messages |
| 2007年08月23日 15:58:15 | admin | create |
|