TypeCheck vs IsInstance in C API

random832 at fastmail.us random832 at fastmail.us
Tue Aug 25 13:42:44 EDT 2015


On Tue, Aug 25, 2015, at 12:56, Terry Reedy wrote:
> Huh??  I fail to see the point of this buggy code.
...
> The extra marginal '>' quote makes it look like this buggy code was 
> posted by Andrew, but it comes from random832.

Actually, it comes from one of the links I posted right above it. It
was, apparently, the recommended way to do this in python up to 1.4,
before isinstance existed.

It only worked with [old-style, goes without saying] instance and class
objects and not, say, ints, but AFAICT isinstance in 1.5 didn't support
anything else either. Since these couldn't be subclassed you could
simply add "if type(cl) is types.TypeType: return type(ob) is cl" to the
top.



More information about the Python-list mailing list