Movatterモバイル変換


[0]ホーム

URL:


Navigation

Class and Instance Objects

Note that the class objects described here represent old-style classes, whichwill go away in Python 3. When creating new types for extension modules, youwill want to work with type objects (sectionType Objects).

PyClassObject
The C structure of the objects used to describe built-in classes.
PyObject*PyClass_Type

This is the type object for class objects; it is the same object astypes.ClassType in the Python layer.

intPyClass_Check(PyObject *o)
Return true if the objecto is a class object, including instances of typesderived from the standard class object. Return false in all other cases.
intPyClass_IsSubclass(PyObject *klass,PyObject *base)
Return true ifklass is a subclass ofbase. Return false in all other cases.

There are very few functions specific to instance objects.

PyTypeObjectPyInstance_Type
Type object for class instances.
intPyInstance_Check(PyObject *obj)
Return true ifobj is an instance.
PyObject*PyInstance_New(PyObject *class,PyObject *arg,PyObject *kw)
Return value: New reference.

Create a new instance of a specific class. The parametersarg andkw areused as the positional and keyword parameters to the object’s constructor.

PyObject*PyInstance_NewRaw(PyObject *class,PyObject *dict)
Return value: New reference.

Create a new instance of a specific class without calling its constructor.class is the class of new object. Thedict parameter will be used as theobject’s__dict__; ifNULL, a new dictionary will be created for theinstance.

Previous topic

Dictionary Objects

Next topic

Function Objects

This Page

Quick search

Navigation

©Copyright 1990-2008, Python Software Foundation. Last updated on Oct 02, 2008. Created usingSphinx 0.5.

[8]ページ先頭

©2009-2026 Movatter.jp