New-style objects are not instances, apparently

Fredrik Lundh fredrik at pythonware.com
Thu Jan 3 16:31:06 EST 2008


eefacm at gmail.com wrote:

> Further experimentation showed that derivation from object was the
> culprit; new-style objects are not considered "instances" in the above
> sense.  I wasn't able to figure out a workaround.  Is there one, or is
> the distinction between traditional classes and built-in types only
> going to get more and more hazy?

new-style classes *are* types.

one way to test for a new-style object is to compare type(obj) to 
obj.__class__; if they point to the same object, it's a new-style object.

</F>




More information about the Python-list mailing list