isinstance is broken

Michael Hudson mwh at python.net
Mon Jan 20 05:56:34 EST 2003


Carl Banks <imbosol at vt.edu> writes:

> I think a C extension could create an object that is not an instance
> of object, in which case isinstance(something,object) would return
> false.

I think not, because a type is always an object.

isinstance(c, object) == issubclass(type(c), object) == True.
                      ^
           except for old-style instances 

My reading of the source would seem to confirm this, but I could well
have missed something...

Cheers,
M.

-- 
  My hat is lined with tinfoil for protection in the unlikely event
  that the droid gets his PowerPoint presentation working.
                               -- Alan W. Frame, alt.sysadmin.recovery




More information about the Python-list mailing list