[Python-bugs-list] [ python-Bugs-751321 ] Classes inheritig from object are not class type.
SourceForge.net
noreply@sourceforge.net
Tue, 10 Jun 2003 11:07:25 -0700
Bugs item #751321, was opened at 2003-06-09 15:33
Message generated for change (Comment added) made by doerwalter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=751321&group_id=5470
Category: Extension Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Roger Wenham (e078120)
Assigned to: Nobody/Anonymous (nobody)
Summary: Classes inheritig from object are not class type.
Initial Comment:
Isinstance(<classinstance>, types.ClassType) will
return false if the class inherits from object.
Here is a demo:
import types
class a:
def test(self):
pass
class b(object):
def test(self):
pass
if __name__ == '__main__':
if isinstance(a, types.ClassType):
print "a is a class"
else:
print "a is not a class"
if isinstance(b, types.ClassType):
print "b is a class"
else:
print "b is not a class"
The output look like this:
roger@linux_lap:~ > python demo.py
a is a class
b is not a class
----------------------------------------------------------------------
>Comment By: Walter Dörwald (doerwalter)
Date: 2003-06-10 20:07
Message:
Logged In: YES
user_id=89016
The reason for this is that new style classes have a
different meta class than classic classes. This is
documented in http://www.python.org/2.2.3/descrintro.html:
"""The built-in 'type' is the most common metaclass; it is
the metaclass of all built-in types. Classic classes use a
different metaclass: the type known as types.ClassType."""
Why do you think this is a bug?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=751321&group_id=5470