C API: how to tell if x is a new style instance?

Mike C. Fletcher mcfletch at rogers.com
Wed Jan 28 15:56:02 EST 2004


Well, I don't actually know how to check for the spiritual state of a 
new-style class, but here's how to tell if an instance is an instance of 
a new-style class:

    * Note that a new-style class is a sub-class of type, while
      old-style classes are not
    * Check if isinstance( instance.__class__, type )
    * <Insert mystical spiritual damnedness check here>

HTH,
Mike

Michal Vitecek wrote:

> hello everyone,
>
> i've tried to find a way to determine in the python C-API if x is an
> instance of a (damned) new style class, but failed :/
>
> can someone please tell me how this could be accomplished?
>
>        thank you,
>  
>
_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/






More information about the Python-list mailing list