Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
21dc5bac
Kaydet (Commit)
21dc5bac
authored
Tem 11, 2009
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#6421: The self argument of module-level PyCFunctions is now a reference to the module object.
üst
216cca7d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
13 deletions
+9
-13
structures.rst
Doc/c-api/structures.rst
+7
-9
extending.rst
Doc/extending/extending.rst
+2
-4
No files found.
Doc/c-api/structures.rst
Dosyayı görüntüle @
21dc5bac
...
...
@@ -146,12 +146,10 @@ convention flags can be combined with a binding flag.
This is the typical calling convention, where the methods have the type
:ctype:`PyCFunction`. The function expects two :ctype:`PyObject\*` values.
The first one is the *self* object for methods; for module functions, it
has the value given to :cfunc:`Py_InitModule4` (or *NULL* if
:cfunc:`Py_InitModule` was used). The second parameter (often called
*args*) is a tuple object representing all arguments. This parameter is
typically processed using :cfunc:`PyArg_ParseTuple` or
:cfunc:`PyArg_UnpackTuple`.
The first one is the *self* object for methods; for module functions, it is
the module object. The second parameter (often called *args*) is a tuple
object representing all arguments. This parameter is typically processed
using :cfunc:`PyArg_ParseTuple` or :cfunc:`PyArg_UnpackTuple`.
.. data:: METH_KEYWORDS
...
...
@@ -167,9 +165,9 @@ convention flags can be combined with a binding flag.
Methods without parameters don't need to check whether arguments are given if
they are listed with the :const:`METH_NOARGS` flag. They need to be of type
:ctype:`PyCFunction`.
When used with object methods, the first parameter is
typically named ``self`` and will hold a reference to the object instance.
In all cases the second
parameter will be *NULL*.
:ctype:`PyCFunction`.
The first parameter is typically named *self* and will
hold a reference to the module or object instance. In all cases the second
parameter will be *NULL*.
.. data:: METH_O
...
...
Doc/extending/extending.rst
Dosyayı görüntüle @
21dc5bac
...
...
@@ -82,10 +82,8 @@ example, the single expression ``"ls -l"``) to the arguments passed to the C
function. The C function always has two arguments, conventionally named *self*
and *args*.
The *self* argument is only used when the C function implements a built-in
method, not a function. In the example, *self* will always be a *NULL* pointer,
since we are defining a function, not a method. (This is done so that the
interpreter doesn't have to understand two different types of C functions.)
The *self* argument points to the module object for module-level functions;
for a method it would point to the object instance.
The *args* argument will be a pointer to a Python tuple object containing the
arguments. Each item of the tuple corresponds to an argument in the call's
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment