Determining if an object is a class?

placid Bulkan at gmail.com
Thu Jul 13 02:31:53 EDT 2006


Clay_Culver at yahoo.com wrote:
> I need to find out if an object is a class.  Using new style classes
> this is very easy:
>
> class Test(object): pass
>
> obj = Test
>    or
> obj = Test()
>
> if type(obj) == type:
>     # this is a class object..
> else:
>     # this not a class object
>
> But this fails for old style classes.  For example:
>
> class OldStyleObject: pass
>

Why is there old and new classes? What are the differences?

--Cheers




More information about the Python-list mailing list