Classic and New Style Classes?
Leif K-Brooks
eurleif at ecritters.biz
Thu Jun 24 03:58:01 EDT 2004
Chris S. wrote:
> I'm generating the source of an object from a list of objects. Therefore
> I need to determine if the object is a class definition (i.e. 'def
> something(whatever):') or a class instance (i.e. 'somename =
> somethingelse()').
I'm assuming you meant 'class something(whatever):' rather than def. If
so, this should work:
>>> class Foo(object):
... pass
...
>>> isinstance(Foo, type)
True
>>> isinstance(Foo(), type)
False
More information about the Python-list
mailing list