5 Class and Instance Objects
6 --------------------------
8 .. index:: object: class
10 Note that the class objects described here represent old-style classes, which
11 will go away in Python 3. When creating new types for extension modules, you
12 will want to work with type objects (section :ref:`typeobjects`).
15 .. ctype:: PyClassObject
17 The C structure of the objects used to describe built-in classes.
20 .. cvar:: PyObject* PyClass_Type
22 .. index:: single: ClassType (in module types)
24 This is the type object for class objects; it is the same object as
25 ``types.ClassType`` in the Python layer.
28 .. cfunction:: int PyClass_Check(PyObject *o)
30 Return true if the object *o* is a class object, including instances of types
31 derived from the standard class object. Return false in all other cases.
34 .. cfunction:: int PyClass_IsSubclass(PyObject *klass, PyObject *base)
36 Return true if *klass* is a subclass of *base*. Return false in all other cases.
39 .. index:: object: instance
41 There are very few functions specific to instance objects.
44 .. cvar:: PyTypeObject PyInstance_Type
46 Type object for class instances.
49 .. cfunction:: int PyInstance_Check(PyObject *obj)
51 Return true if *obj* is an instance.
54 .. cfunction:: PyObject* PyInstance_New(PyObject *class, PyObject *arg, PyObject *kw)
56 Create a new instance of a specific class. The parameters *arg* and *kw* are
57 used as the positional and keyword parameters to the object's constructor.
60 .. cfunction:: PyObject* PyInstance_NewRaw(PyObject *class, PyObject *dict)
62 Create a new instance of a specific class without calling its constructor.
63 *class* is the class of new object. The *dict* parameter will be used as the
64 object's :attr:`__dict__`; if *NULL*, a new dictionary will be created for the