Determining if an object is a class?
Dino Viehland
dinov at exchange.microsoft.com
Thu Jul 13 00:13:31 EDT 2006
The first check is also off - it should if issubclass(type(Test), type): otherwise you miss the metaclass case:
class foo(type): pass
class Test(object):
__metaclass__ = foo
obj = Test
if type(obj) == type: 'class obj'
else: 'not a class'
just on the off-chance you run into a metaclass :)
-----Original Message-----
From: python-list-bounces+dinov=microsoft.com at python.org [mailto:python-list-bounces+dinov=microsoft.com at python.org] On Behalf Of Clay Culver
Sent: Wednesday, July 12, 2006 2:07 PM
To: python-list at python.org
Subject: Re: Determining if an object is a class?
Ahh much better. Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list