chunk_id stringlengths 36 36 | source stringclasses 35
values | source_url stringlengths 0 290 | upstream_license stringclasses 1
value | document_id stringlengths 36 36 | chunk_index int64 0 324k | retrieved_at stringclasses 2
values | chunker_version stringclasses 4
values | content_hash stringlengths 15 64 | content stringlengths 50 44.7k | namespace stringclasses 9
values | source_name stringclasses 35
values | raw_text stringlengths 50 44.7k | cleaned_text stringlengths 50 44.7k | tags stringclasses 49
values | collection_name stringclasses 11
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
61517b53-5e14-4d1b-bf97-30a64bb591d2 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,490 | supabase-export-v2 | 12b22a3ba0d5e01f | pValue = PyObject_CallObject(pFunc, pArgs);
Upon return of the function, ``pValue`` is either ``NULL`` or it contains a
reference to the return value of the function. Be sure to release the reference
after examining the value. | trusted_official_docs | CPython Docs | pValue = PyObject_CallObject(pFunc, pArgs);
Upon return of the function, ``pValue`` is either ``NULL`` or it contains a
reference to the return value of the function. Be sure to release the reference
after examining the value. | pValue = PyObject_CallObject(pFunc, pArgs);
Upon return of the function, ``pValue`` is either ``NULL`` or it contains a
reference to the return value of the function. Be sure to release the reference
after examining the value. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7a1ff01a-ff54-456b-8b6e-3affdeb0b560 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,464 | supabase-export-v2 | 4cbc1876efb29e47 | intent. Most topics discussed in the previous chapters are still valid. To show this, consider what the extension code from Python to C really does:
#. Convert data values from Python to C, | trusted_official_docs | CPython Docs | intent. Most topics discussed in the previous chapters are still valid. To show this, consider what the extension code from Python to C really does:
#. Convert data values from Python to C, | intent. Most topics discussed in the previous chapters are still valid. To show this, consider what the extension code from Python to C really does:
#. Convert data values from Python to C, | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8075eb64-6013-4589-aac8-3a7eb7b334d8 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,496 | supabase-export-v2 | 7cf2786b70fdd3a8 | Return the number of arguments of the application command line */ static PyObject* emb_numargs(PyObject *self, PyObject *args) { if(!PyArg_ParseTuple(args, ":numargs")) return NULL; return PyLong_FromLong(numargs); }
static PyMethodDef emb_module_methods[] = {
{"numargs", emb_numargs, METH_VARARGS,
"Return the number... | trusted_official_docs | CPython Docs | Return the number of arguments of the application command line */ static PyObject* emb_numargs(PyObject *self, PyObject *args) { if(!PyArg_ParseTuple(args, ":numargs")) return NULL; return PyLong_FromLong(numargs); }
static PyMethodDef emb_module_methods[] = {
{"numargs", emb_numargs, METH_VARARGS,
"Return the number... | Return the number of arguments of the application command line */ static PyObject* emb_numargs(PyObject *self, PyObject *args) { if(!PyArg_ParseTuple(args, ":numargs")) return NULL; return PyLong_FromLong(numargs); }
static PyMethodDef emb_module_methods[] = {
{"numargs", emb_numargs, METH_VARARGS,
"Return the number... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8243f8d5-3038-4701-ae15-703c41077e29 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,462 | supabase-export-v2 | 06adb873f145faf5 | Beyond Very High Level Embedding: An overview =============================================
The high level interface gives you the ability to execute arbitrary pieces of
Python code from your application, but exchanging data values is quite
cumbersome to say the least. If you want that, you should use lower level calls... | trusted_official_docs | CPython Docs | Beyond Very High Level Embedding: An overview =============================================
The high level interface gives you the ability to execute arbitrary pieces of
Python code from your application, but exchanging data values is quite
cumbersome to say the least. If you want that, you should use lower level calls... | Beyond Very High Level Embedding: An overview =============================================
The high level interface gives you the ability to execute arbitrary pieces of
Python code from your application, but exchanging data values is quite
cumbersome to say the least. If you want that, you should use lower level calls... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
83e33994-4f07-40c4-9017-66b477822f40 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,497 | supabase-export-v2 | 3d5e9ecbdefc9b8a | static PyMethodDef emb_module_methods[] = { {"numargs", emb_numargs, METH_VARARGS, "Return the number of arguments received by the process."}, {NULL, NULL, 0, NULL} };
static struct PyModuleDef emb_module = {
.m_base = PyModuleDef_HEAD_INIT,
.m_name = "emb",
.m_size = 0,
.m_methods = emb_module_methods,
}; | trusted_official_docs | CPython Docs | static PyMethodDef emb_module_methods[] = { {"numargs", emb_numargs, METH_VARARGS, "Return the number of arguments received by the process."}, {NULL, NULL, 0, NULL} };
static struct PyModuleDef emb_module = {
.m_base = PyModuleDef_HEAD_INIT,
.m_name = "emb",
.m_size = 0,
.m_methods = emb_module_methods,
}; | static PyMethodDef emb_module_methods[] = { {"numargs", emb_numargs, METH_VARARGS, "Return the number of arguments received by the process."}, {NULL, NULL, 0, NULL} };
static struct PyModuleDef emb_module = {
.m_base = PyModuleDef_HEAD_INIT,
.m_name = "emb",
.m_size = 0,
.m_methods = emb_module_methods,
}; | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9e2624b7-27ba-4211-9537-aef6bed1f0f1 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,472 | supabase-export-v2 | b9a12130a1823013 | difference is the routine that you call between both data conversions. When extending, you call a C routine, when embedding, you call a Python routine.
This chapter will not discuss how to convert data from Python to C and vice
versa. Also, proper use of references and dealing with errors is assumed to be
understood. S... | trusted_official_docs | CPython Docs | difference is the routine that you call between both data conversions. When extending, you call a C routine, when embedding, you call a Python routine.
This chapter will not discuss how to convert data from Python to C and vice
versa. Also, proper use of references and dealing with errors is assumed to be
understood. S... | difference is the routine that you call between both data conversions. When extending, you call a C routine, when embedding, you call a Python routine.
This chapter will not discuss how to convert data from Python to C and vice
versa. Also, proper use of references and dealing with errors is assumed to be
understood. S... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a6486d45-19fa-423a-aae2-9e210030ebd5 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,475 | supabase-export-v2 | 97351e052fbb2ed3 | section about the very high level interface, the Python interpreter does not directly interact with the application (but that will change in the next section).
The code to run a function defined in a Python script is: | trusted_official_docs | CPython Docs | section about the very high level interface, the Python interpreter does not directly interact with the application (but that will change in the next section).
The code to run a function defined in a Python script is: | section about the very high level interface, the Python interpreter does not directly interact with the application (but that will change in the next section).
The code to run a function defined in a Python script is: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a6f635b7-7e9d-4efb-a677-6790b4c3659d | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,474 | supabase-export-v2 | ddc11b604657fea9 | Pure Embedding ==============
The first program aims to execute a function in a Python script. Like in the
section about the very high level interface, the Python interpreter does not
directly interact with the application (but that will change in the next
section). | trusted_official_docs | CPython Docs | Pure Embedding ==============
The first program aims to execute a function in a Python script. Like in the
section about the very high level interface, the Python interpreter does not
directly interact with the application (but that will change in the next
section). | Pure Embedding ==============
The first program aims to execute a function in a Python script. Like in the
section about the very high level interface, the Python interpreter does not
directly interact with the application (but that will change in the next
section). | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ab9b3acd-d109-4559-99a4-9bb6a62dbf4d | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,445 | supabase-export-v2 | 9451d510082c130a | :c:func:`Py_Initialize`. There are optional calls to pass command line arguments to Python. Then later you can call the interpreter from any part of the application.
There are several different ways to call the interpreter: you can pass a string
containing Python statements to :c:func:`PyRun_SimpleString`, or you can p... | trusted_official_docs | CPython Docs | :c:func:`Py_Initialize`. There are optional calls to pass command line arguments to Python. Then later you can call the interpreter from any part of the application.
There are several different ways to call the interpreter: you can pass a string
containing Python statements to :c:func:`PyRun_SimpleString`, or you can p... | :c:func:`Py_Initialize`. There are optional calls to pass command line arguments to Python. Then later you can call the interpreter from any part of the application.
There are several different ways to call the interpreter: you can pass a string
containing Python statements to :c:func:`PyRun_SimpleString`, or you can p... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ae57dcee-09c2-4759-9f11-3a08a0bc7ea7 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,459 | supabase-export-v2 | 0efcfe4c1c2e33ff | of ``int``. It is not necessary since Python 3.13, but we keep it here for backward compatibility. See :ref:`arg-parsing-string-and-buffers` for a description of this macro.
Setting :c:member:`PyConfig.program_name` should be called before
:c:func:`Py_InitializeFromConfig` to inform the interpreter about paths to Pytho... | trusted_official_docs | CPython Docs | of ``int``. It is not necessary since Python 3.13, but we keep it here for backward compatibility. See :ref:`arg-parsing-string-and-buffers` for a description of this macro.
Setting :c:member:`PyConfig.program_name` should be called before
:c:func:`Py_InitializeFromConfig` to inform the interpreter about paths to Pytho... | of ``int``. It is not necessary since Python 3.13, but we keep it here for backward compatibility. See :ref:`arg-parsing-string-and-buffers` for a description of this macro.
Setting :c:member:`PyConfig.program_name` should be called before
:c:func:`Py_InitializeFromConfig` to inform the interpreter about paths to Pytho... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b749e127-def3-482d-919f-4660b505edf2 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,484 | supabase-export-v2 | c512ef83fc3449cc | the code is for data conversion between Python and C, and for error reporting. The interesting part with respect to embedding Python starts with ::
Py_Initialize();
pName = PyUnicode_DecodeFSDefault(argv[1]);
/* Error checking of pName left out */
pModule = PyImport_Import(pName); | trusted_official_docs | CPython Docs | the code is for data conversion between Python and C, and for error reporting. The interesting part with respect to embedding Python starts with ::
Py_Initialize();
pName = PyUnicode_DecodeFSDefault(argv[1]);
/* Error checking of pName left out */
pModule = PyImport_Import(pName); | the code is for data conversion between Python and C, and for error reporting. The interesting part with respect to embedding Python starts with ::
Py_Initialize();
pName = PyUnicode_DecodeFSDefault(argv[1]);
/* Error checking of pName left out */
pModule = PyImport_Import(pName); | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bb482030-a32e-42f7-b40a-3db8c7e94dc5 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,477 | supabase-export-v2 | c22cc43cca26ecf2 | .. literalinclude:: ../includes/run-func.c
This code loads a Python script using ``argv[1]``, and calls the function named
in ``argv[2]``. Its integer arguments are the other values of the ``argv``
array. If you :ref:`compile and link <compiling>` this program (let's call
the finished executable :program:`call`), and u... | trusted_official_docs | CPython Docs | .. literalinclude:: ../includes/run-func.c
This code loads a Python script using ``argv[1]``, and calls the function named
in ``argv[2]``. Its integer arguments are the other values of the ``argv``
array. If you :ref:`compile and link <compiling>` this program (let's call
the finished executable :program:`call`), and u... | .. literalinclude:: ../includes/run-func.c
This code loads a Python script using ``argv[1]``, and calls the function named
in ``argv[2]``. Its integer arguments are the other values of the ``argv``
array. If you :ref:`compile and link <compiling>` this program (let's call
the finished executable :program:`call`), and u... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
be2d38f3-40fb-4714-8638-ebe879a0c188 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,488 | supabase-export-v2 | 9cc24c14879d45d6 | if (pFunc && PyCallable_Check(pFunc)) { ... } Py_XDECREF(pFunc);
Once the script is loaded, the name we're looking for is retrieved using
:c:func:`PyObject_GetAttrString`. If the name exists, and the object returned is
callable, you can safely assume that it is a function. The program then
proceeds by constructing a tu... | trusted_official_docs | CPython Docs | if (pFunc && PyCallable_Check(pFunc)) { ... } Py_XDECREF(pFunc);
Once the script is loaded, the name we're looking for is retrieved using
:c:func:`PyObject_GetAttrString`. If the name exists, and the object returned is
callable, you can safely assume that it is a function. The program then
proceeds by constructing a tu... | if (pFunc && PyCallable_Check(pFunc)) { ... } Py_XDECREF(pFunc);
Once the script is loaded, the name we're looking for is retrieved using
:c:func:`PyObject_GetAttrString`. If the name exists, and the object returned is
callable, you can safely assume that it is a function. The program then
proceeds by constructing a tu... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
be79acd0-b326-4335-91aa-f4e8627e9369 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,463 | supabase-export-v2 | 739a2ec957ba9f10 | If you want that, you should use lower level calls. At the cost of having to write more C code, you can achieve almost anything.
It should be noted that extending Python and embedding Python is quite the same
activity, despite the different intent. Most topics discussed in the previous
chapters are still valid. To show... | trusted_official_docs | CPython Docs | If you want that, you should use lower level calls. At the cost of having to write more C code, you can achieve almost anything.
It should be noted that extending Python and embedding Python is quite the same
activity, despite the different intent. Most topics discussed in the previous
chapters are still valid. To show... | If you want that, you should use lower level calls. At the cost of having to write more C code, you can achieve almost anything.
It should be noted that extending Python and embedding Python is quite the same
activity, despite the different intent. Most topics discussed in the previous
chapters are still valid. To show... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ca2cf7cf-9948-4da8-bc5f-cc72e15a4018 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,501 | supabase-export-v2 | ada517c8582daf41 | numargs = argc; PyImport_AppendInittab("emb", &PyInit_emb);
These two lines initialize the ``numargs`` variable, and make the
:func:`!emb.numargs` function accessible to the embedded Python interpreter. With these extensions, the Python script can do things like | trusted_official_docs | CPython Docs | numargs = argc; PyImport_AppendInittab("emb", &PyInit_emb);
These two lines initialize the ``numargs`` variable, and make the
:func:`!emb.numargs` function accessible to the embedded Python interpreter. With these extensions, the Python script can do things like | numargs = argc; PyImport_AppendInittab("emb", &PyInit_emb);
These two lines initialize the ``numargs`` variable, and make the
:func:`!emb.numargs` function accessible to the embedded Python interpreter. With these extensions, the Python script can do things like | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
d778700f-5557-4f22-9762-12ebfcad51d6 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,508 | supabase-export-v2 | e88ae608ea56d733 | Embedding Python in C++ =======================
It is also possible to embed Python in a C++ program; precisely how this is done
will depend on the details of the C++ system used; in general you will need to
write the main program in C++, and use the C++ compiler to compile and link your
program. There is no need to re... | trusted_official_docs | CPython Docs | Embedding Python in C++ =======================
It is also possible to embed Python in a C++ program; precisely how this is done
will depend on the details of the C++ system used; in general you will need to
write the main program in C++, and use the C++ compiler to compile and link your
program. There is no need to re... | Embedding Python in C++ =======================
It is also possible to embed Python in a C++ program; precisely how this is done
will depend on the details of the C++ system used; in general you will need to
write the main program in C++, and use the C++ compiler to compile and link your
program. There is no need to re... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
defad5ef-ab73-44e3-8adc-4e96d859130a | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,442 | supabase-export-v2 | 7d3e65072a3cdec4 | *************************************** Embedding Python in Another Application ***************************************
The previous chapters discussed how to extend Python, that is, how to extend the
functionality of Python by attaching a library of C functions to it. It is also
possible to do it the other way around:... | trusted_official_docs | CPython Docs | *************************************** Embedding Python in Another Application ***************************************
The previous chapters discussed how to extend Python, that is, how to extend the
functionality of Python by attaching a library of C functions to it. It is also
possible to do it the other way around:... | *************************************** Embedding Python in Another Application ***************************************
The previous chapters discussed how to extend Python, that is, how to extend the
functionality of Python by attaching a library of C functions to it. It is also
possible to do it the other way around:... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ede4f9b2-e5b4-4cc6-bc62-f10691cbc4a7 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,493 | supabase-export-v2 | aea2f73ff90df66d | Extending Embedded Python =========================
Until now, the embedded Python interpreter had no access to functionality from
the application itself. The Python API allows this by extending the embedded
interpreter. That is, the embedded interpreter gets extended with routines
provided by the application. While it... | trusted_official_docs | CPython Docs | Extending Embedded Python =========================
Until now, the embedded Python interpreter had no access to functionality from
the application itself. The Python API allows this by extending the embedded
interpreter. That is, the embedded interpreter gets extended with routines
provided by the application. While it... | Extending Embedded Python =========================
Until now, the embedded Python interpreter had no access to functionality from
the application itself. The Python API allows this by extending the embedded
interpreter. That is, the embedded interpreter gets extended with routines
provided by the application. While it... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ee863f83-317e-40c9-8e09-153f3338b8ad | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,486 | supabase-export-v2 | 2749dc489bef2c14 | the script is loaded using :c:func:`PyImport_Import`. This routine needs a Python string as its argument, which is constructed using the :c:func:`PyUnicode_DecodeFSDefault` data conversion routine. ::
pFunc = PyObject_GetAttrString(pModule, argv[2]);
/* pFunc is a new reference */ | trusted_official_docs | CPython Docs | the script is loaded using :c:func:`PyImport_Import`. This routine needs a Python string as its argument, which is constructed using the :c:func:`PyUnicode_DecodeFSDefault` data conversion routine. ::
pFunc = PyObject_GetAttrString(pModule, argv[2]);
/* pFunc is a new reference */ | the script is loaded using :c:func:`PyImport_Import`. This routine needs a Python string as its argument, which is constructed using the :c:func:`PyUnicode_DecodeFSDefault` data conversion routine. ::
pFunc = PyObject_GetAttrString(pModule, argv[2]);
/* pFunc is a new reference */ | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f8e6babd-854f-44db-abc8-b444d921e599 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,471 | supabase-export-v2 | 3450e3bc43633f8d | #. Convert the data values from the call from Python to C.
As you can see, the data conversion steps are simply swapped to accommodate the
different direction of the cross-language transfer. The only difference is the
routine that you call between both data conversions. When extending, you call a
C routine, when embedd... | trusted_official_docs | CPython Docs | #. Convert the data values from the call from Python to C.
As you can see, the data conversion steps are simply swapped to accommodate the
different direction of the cross-language transfer. The only difference is the
routine that you call between both data conversions. When extending, you call a
C routine, when embedd... | #. Convert the data values from the call from Python to C.
As you can see, the data conversion steps are simply swapped to accommodate the
different direction of the cross-language transfer. The only difference is the
routine that you call between both data conversions. When extending, you call a
C routine, when embedd... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f9043252-6ac0-41c4-bc5b-e66645ece1ae | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,483 | supabase-export-v2 | 473a62b919beea4f | $ call multiply multiply 3 2 Will compute 3 times 2 Result of call: 6
Although the program is quite large for its functionality, most of the code is
for data conversion between Python and C, and for error reporting. The
interesting part with respect to embedding Python starts with :: | trusted_official_docs | CPython Docs | $ call multiply multiply 3 2 Will compute 3 times 2 Result of call: 6
Although the program is quite large for its functionality, most of the code is
for data conversion between Python and C, and for error reporting. The
interesting part with respect to embedding Python starts with :: | $ call multiply multiply 3 2 Will compute 3 times 2 Result of call: 6
Although the program is quite large for its functionality, most of the code is
for data conversion between Python and C, and for error reporting. The
interesting part with respect to embedding Python starts with :: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fddc4684-db75-4857-8b4c-107c7a098ff7 | CPython Docs | file://datasets/cpython/Doc/extending/embedding.rst | unknown | 3dadfc00-38ea-4a45-841b-b4dc3757dc7e | 1,444 | supabase-export-v2 | 74424bfd21630190 | program may have nothing to do with Python --- instead, some parts of the application occasionally call the Python interpreter to run some Python code.
So if you are embedding Python, you are providing your own main program. One of
the things this main program has to do is initialize the Python interpreter. At
the very... | trusted_official_docs | CPython Docs | program may have nothing to do with Python --- instead, some parts of the application occasionally call the Python interpreter to run some Python code.
So if you are embedding Python, you are providing your own main program. One of
the things this main program has to do is initialize the Python interpreter. At
the very... | program may have nothing to do with Python --- instead, some parts of the application occasionally call the Python interpreter to run some Python code.
So if you are embedding Python, you are providing your own main program. One of
the things this main program has to do is initialize the Python interpreter. At
the very... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
245109dc-ba3e-4460-b203-c32481534138 | CPython Docs | file://datasets/cpython/Doc/extending/index.rst | unknown | 4c6af6fc-ddb9-4ff4-a24d-dc6dee8586ed | 1,540 | supabase-export-v2 | 04f40a3437d37b92 | Guides for intermediate topics ==============================
This section of the guide covers creating C and C++ extensions without
assistance from third party tools. It is intended primarily for creators
of those tools, rather than being a recommended way to create your own
C extensions. | trusted_official_docs | CPython Docs | Guides for intermediate topics ==============================
This section of the guide covers creating C and C++ extensions without
assistance from third party tools. It is intended primarily for creators
of those tools, rather than being a recommended way to create your own
C extensions. | Guides for intermediate topics ==============================
This section of the guide covers creating C and C++ extensions without
assistance from third party tools. It is intended primarily for creators
of those tools, rather than being a recommended way to create your own
C extensions. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
304531b6-78d8-4cd5-bf64-995402455561 | CPython Docs | file://datasets/cpython/Doc/extending/index.rst | unknown | 4c6af6fc-ddb9-4ff4-a24d-dc6dee8586ed | 1,526 | supabase-export-v2 | f062e4291449f2b8 | and link extension modules so that they can be loaded dynamically (at run time) into the interpreter, if the underlying operating system supports this feature.
This document assumes basic knowledge about C and Python. For an informal
introduction to Python, see :ref:`tutorial-index`. :ref:`reference-index`
gives a more... | trusted_official_docs | CPython Docs | and link extension modules so that they can be loaded dynamically (at run time) into the interpreter, if the underlying operating system supports this feature.
This document assumes basic knowledge about C and Python. For an informal
introduction to Python, see :ref:`tutorial-index`. :ref:`reference-index`
gives a more... | and link extension modules so that they can be loaded dynamically (at run time) into the interpreter, if the underlying operating system supports this feature.
This document assumes basic knowledge about C and Python. For an informal
introduction to Python, see :ref:`tutorial-index`. :ref:`reference-index`
gives a more... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
383f5fca-875c-484b-bb11-5bd9eebae4eb | CPython Docs | file://datasets/cpython/Doc/extending/index.rst | unknown | 4c6af6fc-ddb9-4ff4-a24d-dc6dee8586ed | 1,541 | supabase-export-v2 | 93d1fa33d0741e3a | from third party tools. It is intended primarily for creators of those tools, rather than being a recommended way to create your own C extensions.
* :ref:`extending-intro`
* :ref:`defining-new-types`
* :ref:`new-types-topics`
* :ref:`building`
* :ref:`building-on-windows` | trusted_official_docs | CPython Docs | from third party tools. It is intended primarily for creators of those tools, rather than being a recommended way to create your own C extensions.
* :ref:`extending-intro`
* :ref:`defining-new-types`
* :ref:`new-types-topics`
* :ref:`building`
* :ref:`building-on-windows` | from third party tools. It is intended primarily for creators of those tools, rather than being a recommended way to create your own C extensions.
* :ref:`extending-intro`
* :ref:`defining-new-types`
* :ref:`new-types-topics`
* :ref:`building`
* :ref:`building-on-windows` | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5a635b18-c2fd-4c22-90c6-e3f2c967a888 | CPython Docs | file://datasets/cpython/Doc/extending/index.rst | unknown | 4c6af6fc-ddb9-4ff4-a24d-dc6dee8586ed | 1,534 | supabase-export-v2 | 2bec2e70356864c2 | Recommended third party tools =============================
This document only covers the basic tools for creating extensions provided
as part of this version of CPython. Some :ref:`third party tools
<c-api-tools>` offer both simpler and more sophisticated approaches to creating
C and C++ extensions for Python. | trusted_official_docs | CPython Docs | Recommended third party tools =============================
This document only covers the basic tools for creating extensions provided
as part of this version of CPython. Some :ref:`third party tools
<c-api-tools>` offer both simpler and more sophisticated approaches to creating
C and C++ extensions for Python. | Recommended third party tools =============================
This document only covers the basic tools for creating extensions provided
as part of this version of CPython. Some :ref:`third party tools
<c-api-tools>` offer both simpler and more sophisticated approaches to creating
C and C++ extensions for Python. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6ed099ba-4ac8-4b84-a6ad-98a042b042b7 | CPython Docs | file://datasets/cpython/Doc/extending/index.rst | unknown | 4c6af6fc-ddb9-4ff4-a24d-dc6dee8586ed | 1,527 | supabase-export-v2 | e78ee07e34680029 | the language. :ref:`library-index` documents the existing object types, functions and modules (both built-in and written in Python) that give the language its wide application range.
For a detailed description of the whole Python/C API, see the separate
:ref:`c-api-index`. | trusted_official_docs | CPython Docs | the language. :ref:`library-index` documents the existing object types, functions and modules (both built-in and written in Python) that give the language its wide application range.
For a detailed description of the whole Python/C API, see the separate
:ref:`c-api-index`. | the language. :ref:`library-index` documents the existing object types, functions and modules (both built-in and written in Python) that give the language its wide application range.
For a detailed description of the whole Python/C API, see the separate
:ref:`c-api-index`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6f01607d-abce-4868-9872-e5623656d1b9 | CPython Docs | file://datasets/cpython/Doc/extending/index.rst | unknown | 4c6af6fc-ddb9-4ff4-a24d-dc6dee8586ed | 1,528 | supabase-export-v2 | 20a20ccd922c5eb2 | For a detailed description of the whole Python/C API, see the separate :ref:`c-api-index`.
To support extensions, Python's C API (Application Programmers Interface)
defines a set of functions, macros and variables that provide access to most
aspects of the Python run-time system. The Python API is incorporated in a C
s... | trusted_official_docs | CPython Docs | For a detailed description of the whole Python/C API, see the separate :ref:`c-api-index`.
To support extensions, Python's C API (Application Programmers Interface)
defines a set of functions, macros and variables that provide access to most
aspects of the Python run-time system. The Python API is incorporated in a C
s... | For a detailed description of the whole Python/C API, see the separate :ref:`c-api-index`.
To support extensions, Python's C API (Application Programmers Interface)
defines a set of functions, macros and variables that provide access to most
aspects of the Python run-time system. The Python API is incorporated in a C
s... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
82eb0eaf-80e4-4cfd-9dda-ab29a9c8266f | CPython Docs | file://datasets/cpython/Doc/extending/index.rst | unknown | 4c6af6fc-ddb9-4ff4-a24d-dc6dee8586ed | 1,530 | supabase-export-v2 | 94fe4d1aecc2e4e2 | .. note::
The C extension interface is specific to CPython, and extension modules do
not work on other Python implementations. In many cases, it is possible to
avoid writing C extensions and preserve portability to other implementations. For example, if your use case is calling C library functions or system calls,
y... | trusted_official_docs | CPython Docs | .. note::
The C extension interface is specific to CPython, and extension modules do
not work on other Python implementations. In many cases, it is possible to
avoid writing C extensions and preserve portability to other implementations. For example, if your use case is calling C library functions or system calls,
y... | .. note::
The C extension interface is specific to CPython, and extension modules do
not work on other Python implementations. In many cases, it is possible to
avoid writing C extensions and preserve portability to other implementations. For example, if your use case is calling C library functions or system calls,
y... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ccad736c-42fe-4d53-b6f5-ccb745cebcae | CPython Docs | file://datasets/cpython/Doc/extending/index.rst | unknown | 4c6af6fc-ddb9-4ff4-a24d-dc6dee8586ed | 1,535 | supabase-export-v2 | 41ae6de28619c850 | of this version of CPython. Some :ref:`third party tools <c-api-tools>` offer both simpler and more sophisticated approaches to creating C and C++ extensions for Python.
While this document is aimed at extension authors, it should also be helpful to
the authors of such tools. For example, the tutorial module can serve ... | trusted_official_docs | CPython Docs | of this version of CPython. Some :ref:`third party tools <c-api-tools>` offer both simpler and more sophisticated approaches to creating C and C++ extensions for Python.
While this document is aimed at extension authors, it should also be helpful to
the authors of such tools. For example, the tutorial module can serve ... | of this version of CPython. Some :ref:`third party tools <c-api-tools>` offer both simpler and more sophisticated approaches to creating C and C++ extensions for Python.
While this document is aimed at extension authors, it should also be helpful to
the authors of such tools. For example, the tutorial module can serve ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e659aef3-6773-49f8-b13f-b1d98390e9a0 | CPython Docs | file://datasets/cpython/Doc/extending/index.rst | unknown | 4c6af6fc-ddb9-4ff4-a24d-dc6dee8586ed | 1,543 | supabase-export-v2 | 3b56840dfbbd1a53 | Embedding the CPython runtime in a larger application =====================================================
Sometimes, rather than creating an extension that runs inside the Python
interpreter as the main application, it is desirable to instead embed
the CPython runtime inside a larger application. This section covers
... | trusted_official_docs | CPython Docs | Embedding the CPython runtime in a larger application =====================================================
Sometimes, rather than creating an extension that runs inside the Python
interpreter as the main application, it is desirable to instead embed
the CPython runtime inside a larger application. This section covers
... | Embedding the CPython runtime in a larger application =====================================================
Sometimes, rather than creating an extension that runs inside the Python
interpreter as the main application, it is desirable to instead embed
the CPython runtime inside a larger application. This section covers
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e75770e9-c148-40a2-a42a-c6c7212765c1 | CPython Docs | file://datasets/cpython/Doc/extending/index.rst | unknown | 4c6af6fc-ddb9-4ff4-a24d-dc6dee8586ed | 1,537 | supabase-export-v2 | 148d2b489c8752b0 | C API Tutorial ==============
This tutorial describes how to write a simple module in C or C++,
using the Python C API -- that is, using the basic tools provided
as part of this version of CPython. | trusted_official_docs | CPython Docs | C API Tutorial ==============
This tutorial describes how to write a simple module in C or C++,
using the Python C API -- that is, using the basic tools provided
as part of this version of CPython. | C API Tutorial ==============
This tutorial describes how to write a simple module in C or C++,
using the Python C API -- that is, using the basic tools provided
as part of this version of CPython. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fb34d714-a68c-4c53-a190-cc00d71779ed | CPython Docs | file://datasets/cpython/Doc/extending/index.rst | unknown | 4c6af6fc-ddb9-4ff4-a24d-dc6dee8586ed | 1,525 | supabase-export-v2 | 9cf88554579cbaab | ################################################## Extending and Embedding the Python Interpreter ##################################################
This document describes how to write modules in C or C++ to extend the Python
interpreter with new modules. Those modules can do what Python code does --
define functions,... | trusted_official_docs | CPython Docs | ################################################## Extending and Embedding the Python Interpreter ##################################################
This document describes how to write modules in C or C++ to extend the Python
interpreter with new modules. Those modules can do what Python code does --
define functions,... | ################################################## Extending and Embedding the Python Interpreter ##################################################
This document describes how to write modules in C or C++ to extend the Python
interpreter with new modules. Those modules can do what Python code does --
define functions,... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
07f1b620-3359-41cd-8e3d-2114edc5940e | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,559 | supabase-export-v2 | 47ed1f5a87d09185 | Call the function :c:func:`PyRun_String` from the previous question with the start symbol :c:data:`Py_eval_input`; it parses an expression, evaluates it and returns its value.
How do I extract C values from a Python object? ----------------------------------------------- | trusted_official_docs | CPython Docs | Call the function :c:func:`PyRun_String` from the previous question with the start symbol :c:data:`Py_eval_input`; it parses an expression, evaluates it and returns its value.
How do I extract C values from a Python object? ----------------------------------------------- | Call the function :c:func:`PyRun_String` from the previous question with the start symbol :c:data:`Py_eval_input`; it parses an expression, evaluates it and returns its value.
How do I extract C values from a Python object? ----------------------------------------------- | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
08f8766e-3e46-476e-905a-df3ed2b4deb1 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,563 | supabase-export-v2 | 885a4a79c2a0da64 | To test the type of an object, first make sure it isn't ``NULL``, and then use :c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, etc.
There is also a high-level API to Python objects which is provided by the
so-called 'abstract' interface -- read ``Include/abstract.h`` for further
details. It al... | trusted_official_docs | CPython Docs | To test the type of an object, first make sure it isn't ``NULL``, and then use :c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, etc.
There is also a high-level API to Python objects which is provided by the
so-called 'abstract' interface -- read ``Include/abstract.h`` for further
details. It al... | To test the type of an object, first make sure it isn't ``NULL``, and then use :c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, etc.
There is also a high-level API to Python objects which is provided by the
so-called 'abstract' interface -- read ``Include/abstract.h`` for further
details. It al... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
153ff384-1f80-45ad-88c3-871b36a74dc6 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,568 | supabase-export-v2 | 2c315405301bece5 | object. The parameters are the object, the name of the method to call, a format string like that used with :c:func:`Py_BuildValue`, and the argument values::
PyObject *
PyObject_CallMethod(PyObject *object, const char *method_name,
const char *arg_format, ...); | trusted_official_docs | CPython Docs | object. The parameters are the object, the name of the method to call, a format string like that used with :c:func:`Py_BuildValue`, and the argument values::
PyObject *
PyObject_CallMethod(PyObject *object, const char *method_name,
const char *arg_format, ...); | object. The parameters are the object, the name of the method to call, a format string like that used with :c:func:`Py_BuildValue`, and the argument values::
PyObject *
PyObject_CallMethod(PyObject *object, const char *method_name,
const char *arg_format, ...); | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
15dbdcc0-ee45-4470-bbd9-7865045dc0dc | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,606 | supabase-export-v2 | 00c275b7f1165750 | How do I tell "incomplete input" from "invalid input"? ------------------------------------------------------
Sometimes you want to emulate the Python interactive interpreter's behavior,
where it gives you a continuation prompt when the input is incomplete (e.g. you
typed the start of an "if" statement or you didn't cl... | trusted_official_docs | CPython Docs | How do I tell "incomplete input" from "invalid input"? ------------------------------------------------------
Sometimes you want to emulate the Python interactive interpreter's behavior,
where it gives you a continuation prompt when the input is incomplete (e.g. you
typed the start of an "if" statement or you didn't cl... | How do I tell "incomplete input" from "invalid input"? ------------------------------------------------------
Sometimes you want to emulate the Python interactive interpreter's behavior,
where it gives you a continuation prompt when the input is incomplete (e.g. you
typed the start of an "if" statement or you didn't cl... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
184de511-ab3c-44c7-8669-c8ad4afa3f08 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,611 | supabase-export-v2 | 61adbdbfed9e390a | Python, relink it using g++ (change LINKCC in the Python Modules Makefile), and link your extension module using g++ (e.g., ``g++ -shared -o mymodule.so mymodule.o``).
Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? ---------------------------------------... | trusted_official_docs | CPython Docs | Python, relink it using g++ (change LINKCC in the Python Modules Makefile), and link your extension module using g++ (e.g., ``g++ -shared -o mymodule.so mymodule.o``).
Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? ---------------------------------------... | Python, relink it using g++ (change LINKCC in the Python Modules Makefile), and link your extension module using g++ (e.g., ``g++ -shared -o mymodule.so mymodule.o``).
Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? ---------------------------------------... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1eaf8ab2-1a0d-48b8-b514-2e8cc88503f4 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,585 | supabase-export-v2 | e16749a12137873b | of ``sys.modules["<modulename>"]``. Note that it doesn't enter the module into any namespace -- it only ensures it has been initialized and is stored in :data:`sys.modules`.
You can then access the module's attributes (i.e. any name defined in the
module) as follows:: | trusted_official_docs | CPython Docs | of ``sys.modules["<modulename>"]``. Note that it doesn't enter the module into any namespace -- it only ensures it has been initialized and is stored in :data:`sys.modules`.
You can then access the module's attributes (i.e. any name defined in the
module) as follows:: | of ``sys.modules["<modulename>"]``. Note that it doesn't enter the module into any namespace -- it only ensures it has been initialized and is stored in :data:`sys.modules`.
You can then access the module's attributes (i.e. any name defined in the
module) as follows:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2729a5aa-ad13-427c-a253-1912d838a1d2 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,570 | supabase-export-v2 | c238c8ed7db81bd4 | This works for any object that has methods -- whether built-in or user-defined. You are responsible for eventually :c:func:`Py_DECREF`\ 'ing the return value.
To call, e.g., a file object's "seek" method with arguments 10, 0 (assuming the
file object pointer is "f"):: | trusted_official_docs | CPython Docs | This works for any object that has methods -- whether built-in or user-defined. You are responsible for eventually :c:func:`Py_DECREF`\ 'ing the return value.
To call, e.g., a file object's "seek" method with arguments 10, 0 (assuming the
file object pointer is "f"):: | This works for any object that has methods -- whether built-in or user-defined. You are responsible for eventually :c:func:`Py_DECREF`\ 'ing the return value.
To call, e.g., a file object's "seek" method with arguments 10, 0 (assuming the
file object pointer is "f"):: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
2bc5ab58-b44f-4d94-9832-51b2b804cbff | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,574 | supabase-export-v2 | 8c4e049d4a49287c | How do I catch the output from PyErr_Print() (or anything that prints to stdout/stderr)? ----------------------------------------------------------------------------------------
In Python code, define an object that supports the ``write()`` method. Assign
this object to :data:`sys.stdout` and :data:`sys.stderr`. Call p... | trusted_official_docs | CPython Docs | How do I catch the output from PyErr_Print() (or anything that prints to stdout/stderr)? ----------------------------------------------------------------------------------------
In Python code, define an object that supports the ``write()`` method. Assign
this object to :data:`sys.stdout` and :data:`sys.stderr`. Call p... | How do I catch the output from PyErr_Print() (or anything that prints to stdout/stderr)? ----------------------------------------------------------------------------------------
In Python code, define an object that supports the ``write()`` method. Assign
this object to :data:`sys.stdout` and :data:`sys.stderr`. Call p... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3dce4eb7-9a7f-4140-b812-d9358a530c51 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,575 | supabase-export-v2 | 6d817e5fce9a65ce | :data:`sys.stdout` and :data:`sys.stderr`. Call print_error, or just allow the standard traceback mechanism to work. Then, the output will go wherever your ``write()`` method sends it.
The easiest way to do this is to use the :class:`io.StringIO` class: | trusted_official_docs | CPython Docs | :data:`sys.stdout` and :data:`sys.stderr`. Call print_error, or just allow the standard traceback mechanism to work. Then, the output will go wherever your ``write()`` method sends it.
The easiest way to do this is to use the :class:`io.StringIO` class: | :data:`sys.stdout` and :data:`sys.stderr`. Call print_error, or just allow the standard traceback mechanism to work. Then, the output will go wherever your ``write()`` method sends it.
The easiest way to do this is to use the :class:`io.StringIO` class: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
40828d4e-ae81-4477-aa52-b53710d3b91c | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,592 | supabase-export-v2 | c0b39e5af7b35df7 | I added a module using the Setup file and the make fails; why? --------------------------------------------------------------
Setup must end in a newline, if there is no newline there, the build process
fails. (Fixing this requires some ugly shell script hackery, and this bug is so
minor that it doesn't seem worth the ... | trusted_official_docs | CPython Docs | I added a module using the Setup file and the make fails; why? --------------------------------------------------------------
Setup must end in a newline, if there is no newline there, the build process
fails. (Fixing this requires some ugly shell script hackery, and this bug is so
minor that it doesn't seem worth the ... | I added a module using the Setup file and the make fails; why? --------------------------------------------------------------
Setup must end in a newline, if there is no newline there, the build process
fails. (Fixing this requires some ugly shell script hackery, and this bug is so
minor that it doesn't seem worth the ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
41837520-0baa-4ef0-8714-1ab6c400e568 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,610 | supabase-export-v2 | 7c49e3f063b3528c | How do I find undefined g++ symbols __builtin_new or __pure_virtual? --------------------------------------------------------------------
To dynamically load g++ extension modules, you must recompile Python, relink it
using g++ (change LINKCC in the Python Modules Makefile), and link your
extension module using g++ (e.... | trusted_official_docs | CPython Docs | How do I find undefined g++ symbols __builtin_new or __pure_virtual? --------------------------------------------------------------------
To dynamically load g++ extension modules, you must recompile Python, relink it
using g++ (change LINKCC in the Python Modules Makefile), and link your
extension module using g++ (e.... | How do I find undefined g++ symbols __builtin_new or __pure_virtual? --------------------------------------------------------------------
To dynamically load g++ extension modules, you must recompile Python, relink it
using g++ (change LINKCC in the Python Modules Makefile), and link your
extension module using g++ (e.... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
469144a3-bbb2-4583-84d6-32107511d2e1 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,573 | supabase-export-v2 | 96c2b55b4888aa6a | call a function without arguments, pass "()" for the format, and to call a function with one argument, surround the argument in parentheses, e.g. "(i)".
How do I catch the output from PyErr_Print() (or anything that prints to stdout/stderr)? ------------------------------------------------------------------------------... | trusted_official_docs | CPython Docs | call a function without arguments, pass "()" for the format, and to call a function with one argument, surround the argument in parentheses, e.g. "(i)".
How do I catch the output from PyErr_Print() (or anything that prints to stdout/stderr)? ------------------------------------------------------------------------------... | call a function without arguments, pass "()" for the format, and to call a function with one argument, surround the argument in parentheses, e.g. "(i)".
How do I catch the output from PyErr_Print() (or anything that prints to stdout/stderr)? ------------------------------------------------------------------------------... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
47176128-24e7-4cbe-9f45-c26d0c0f8404 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,555 | supabase-export-v2 | b42b8747233bb1a9 | what you're trying to do. :ref:`Recommended third party tools <c-api-tools>` offer both simpler and more sophisticated approaches to creating C and C++ extensions for Python.
How can I execute arbitrary Python statements from C? ----------------------------------------------------- | trusted_official_docs | CPython Docs | what you're trying to do. :ref:`Recommended third party tools <c-api-tools>` offer both simpler and more sophisticated approaches to creating C and C++ extensions for Python.
How can I execute arbitrary Python statements from C? ----------------------------------------------------- | what you're trying to do. :ref:`Recommended third party tools <c-api-tools>` offer both simpler and more sophisticated approaches to creating C and C++ extensions for Python.
How can I execute arbitrary Python statements from C? ----------------------------------------------------- | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4e94eedc-b232-42d4-8edc-801d5ba604d1 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,571 | supabase-export-v2 | c0af9596dea8c746 | To call, e.g., a file object's "seek" method with arguments 10, 0 (assuming the file object pointer is "f")::
res = PyObject_CallMethod(f, "seek", "(ii)", 10, 0);
if (res == NULL) {
... an exception occurred ... }
else {
Py_DECREF(res);
} | trusted_official_docs | CPython Docs | To call, e.g., a file object's "seek" method with arguments 10, 0 (assuming the file object pointer is "f")::
res = PyObject_CallMethod(f, "seek", "(ii)", 10, 0);
if (res == NULL) {
... an exception occurred ... }
else {
Py_DECREF(res);
} | To call, e.g., a file object's "seek" method with arguments 10, 0 (assuming the file object pointer is "f")::
res = PyObject_CallMethod(f, "seek", "(ii)", 10, 0);
if (res == NULL) {
... an exception occurred ... }
else {
Py_DECREF(res);
} | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5461842b-d211-4d09-aeaf-4533f33eca66 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,562 | supabase-export-v2 | d3013c398af2b4df | provides a pointer to its value and its length. Note that Python bytes objects may contain null bytes so C's :c:func:`!strlen` should not be used.
To test the type of an object, first make sure it isn't ``NULL``, and then use
:c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, etc. | trusted_official_docs | CPython Docs | provides a pointer to its value and its length. Note that Python bytes objects may contain null bytes so C's :c:func:`!strlen` should not be used.
To test the type of an object, first make sure it isn't ``NULL``, and then use
:c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, etc. | provides a pointer to its value and its length. Note that Python bytes objects may contain null bytes so C's :c:func:`!strlen` should not be used.
To test the type of an object, first make sure it isn't ``NULL``, and then use
:c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:`PyList_Check`, etc. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
54d5ec47-72a5-46ee-a97d-0459c424fc06 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,593 | supabase-export-v2 | 21c32caf56914360 | the build process fails. (Fixing this requires some ugly shell script hackery, and this bug is so minor that it doesn't seem worth the effort.)
How do I debug an extension? ---------------------------- | trusted_official_docs | CPython Docs | the build process fails. (Fixing this requires some ugly shell script hackery, and this bug is so minor that it doesn't seem worth the effort.)
How do I debug an extension? ---------------------------- | the build process fails. (Fixing this requires some ugly shell script hackery, and this bug is so minor that it doesn't seem worth the effort.)
How do I debug an extension? ---------------------------- | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
59db403b-cea7-4ec1-a9d9-e9335e030a3e | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,549 | supabase-export-v2 | 7c53c6b40c1b00c8 | Yes, you can create built-in modules containing functions, variables, exceptions and even new types in C. This is explained in the document :ref:`extending-index`.
Most intermediate or advanced Python books will also cover this topic. | trusted_official_docs | CPython Docs | Yes, you can create built-in modules containing functions, variables, exceptions and even new types in C. This is explained in the document :ref:`extending-index`.
Most intermediate or advanced Python books will also cover this topic. | Yes, you can create built-in modules containing functions, variables, exceptions and even new types in C. This is explained in the document :ref:`extending-index`.
Most intermediate or advanced Python books will also cover this topic. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6c997425-89ac-441c-9945-ca20fba665bf | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,569 | supabase-export-v2 | 0560288bae1d4126 | PyObject * PyObject_CallMethod(PyObject *object, const char *method_name, const char *arg_format, ...);
This works for any object that has methods -- whether built-in or user-defined. You are responsible for eventually :c:func:`Py_DECREF`\ 'ing the return value. | trusted_official_docs | CPython Docs | PyObject * PyObject_CallMethod(PyObject *object, const char *method_name, const char *arg_format, ...);
This works for any object that has methods -- whether built-in or user-defined. You are responsible for eventually :c:func:`Py_DECREF`\ 'ing the return value. | PyObject * PyObject_CallMethod(PyObject *object, const char *method_name, const char *arg_format, ...);
This works for any object that has methods -- whether built-in or user-defined. You are responsible for eventually :c:func:`Py_DECREF`\ 'ing the return value. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6f7d5368-3e37-403b-b160-ce4044b66eae | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,600 | supabase-export-v2 | e096d5bfbbd8cf96 | .. code-block:: shell-session
$ gdb /local/bin/python
gdb) run myscript.py
gdb) continue # repeat until your extension is loaded
gdb) finish # so that your extension is loaded
gdb) br myfunction.c:50
gdb) continue | trusted_official_docs | CPython Docs | .. code-block:: shell-session
$ gdb /local/bin/python
gdb) run myscript.py
gdb) continue # repeat until your extension is loaded
gdb) finish # so that your extension is loaded
gdb) br myfunction.c:50
gdb) continue | .. code-block:: shell-session
$ gdb /local/bin/python
gdb) run myscript.py
gdb) continue # repeat until your extension is loaded
gdb) finish # so that your extension is loaded
gdb) br myfunction.c:50
gdb) continue | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7392e351-f11a-4b3b-a3a3-3e9e044832a9 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,557 | supabase-export-v2 | 6ffd7d6e14384b94 | ``0`` for success and ``-1`` when an exception occurred (including :exc:`SyntaxError`). If you want more control, use :c:func:`PyRun_String`; see the source for :c:func:`PyRun_SimpleString` in ``Python/pythonrun.c``.
How can I evaluate an arbitrary Python expression from C? ---------------------------------------------... | trusted_official_docs | CPython Docs | ``0`` for success and ``-1`` when an exception occurred (including :exc:`SyntaxError`). If you want more control, use :c:func:`PyRun_String`; see the source for :c:func:`PyRun_SimpleString` in ``Python/pythonrun.c``.
How can I evaluate an arbitrary Python expression from C? ---------------------------------------------... | ``0`` for success and ``-1`` when an exception occurred (including :exc:`SyntaxError`). If you want more control, use :c:func:`PyRun_String`; see the source for :c:func:`PyRun_SimpleString` in ``Python/pythonrun.c``.
How can I evaluate an arbitrary Python expression from C? ---------------------------------------------... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
79fe5a77-fd1c-41ec-960d-df04accfb1c8 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,561 | supabase-export-v2 | 5206d53630e9a729 | type. If it's a tuple, :c:func:`PyTuple_Size` returns its length and :c:func:`PyTuple_GetItem` returns the item at a specified index. Lists have similar functions, :c:func:`PyList_Size` and :c:func:`PyList_GetItem`.
For bytes, :c:func:`PyBytes_Size` returns its length and
:c:func:`PyBytes_AsStringAndSize` provides a po... | trusted_official_docs | CPython Docs | type. If it's a tuple, :c:func:`PyTuple_Size` returns its length and :c:func:`PyTuple_GetItem` returns the item at a specified index. Lists have similar functions, :c:func:`PyList_Size` and :c:func:`PyList_GetItem`.
For bytes, :c:func:`PyBytes_Size` returns its length and
:c:func:`PyBytes_AsStringAndSize` provides a po... | type. If it's a tuple, :c:func:`PyTuple_Size` returns its length and :c:func:`PyTuple_GetItem` returns the item at a specified index. Lists have similar functions, :c:func:`PyList_Size` and :c:func:`PyList_GetItem`.
For bytes, :c:func:`PyBytes_Size` returns its length and
:c:func:`PyBytes_AsStringAndSize` provides a po... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8c75e4dd-eaa1-4c3b-a66b-22a038d69d71 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,580 | supabase-export-v2 | b7485ee37611b999 | .. code-block:: pycon
>>> import io, sys
>>> class StdoutCatcher(io.TextIOBase):
... def __init__(self):
... self.data = []
... def write(self, stuff):
... self.data.append(stuff)
... >>> import sys
>>> sys.stdout = StdoutCatcher()
>>> print('foo')
>>> print('hello world!')
>>> sys.stderr.write(''.join(sys.st... | trusted_official_docs | CPython Docs | .. code-block:: pycon
>>> import io, sys
>>> class StdoutCatcher(io.TextIOBase):
... def __init__(self):
... self.data = []
... def write(self, stuff):
... self.data.append(stuff)
... >>> import sys
>>> sys.stdout = StdoutCatcher()
>>> print('foo')
>>> print('hello world!')
>>> sys.stderr.write(''.join(sys.st... | .. code-block:: pycon
>>> import io, sys
>>> class StdoutCatcher(io.TextIOBase):
... def __init__(self):
... self.data = []
... def write(self, stuff):
... self.data.append(stuff)
... >>> import sys
>>> sys.stdout = StdoutCatcher()
>>> print('foo')
>>> print('hello world!')
>>> sys.stderr.write(''.join(sys.st... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8ef9bb1f-3b30-4063-8f93-9d067ba18856 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,581 | supabase-export-v2 | 10be1d43411bc5df | [] ... def write(self, stuff): ... self.data.append(stuff) ... >>> import sys >>> sys.stdout = StdoutCatcher() >>> print('foo') >>> print('hello world!') >>> sys.stderr.write(''.join(sys.stdout.data)) foo hello world!
How do I access a module written in Python from C? -------------------------------------------------- | trusted_official_docs | CPython Docs | [] ... def write(self, stuff): ... self.data.append(stuff) ... >>> import sys >>> sys.stdout = StdoutCatcher() >>> print('foo') >>> print('hello world!') >>> sys.stderr.write(''.join(sys.stdout.data)) foo hello world!
How do I access a module written in Python from C? -------------------------------------------------- | [] ... def write(self, stuff): ... self.data.append(stuff) ... >>> import sys >>> sys.stdout = StdoutCatcher() >>> print('foo') >>> print('hello world!') >>> sys.stderr.write(''.join(sys.stdout.data)) foo hello world!
How do I access a module written in Python from C? -------------------------------------------------- | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
95e51f12-3544-4c0e-8385-2e13ab25ef3a | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,554 | supabase-export-v2 | 7e0a24544d34276a | Writing C is hard; are there any alternatives? ----------------------------------------------
There are a number of alternatives to writing your own C extensions, depending
on what you're trying to do. :ref:`Recommended third party tools <c-api-tools>`
offer both simpler and more sophisticated approaches to creating C ... | trusted_official_docs | CPython Docs | Writing C is hard; are there any alternatives? ----------------------------------------------
There are a number of alternatives to writing your own C extensions, depending
on what you're trying to do. :ref:`Recommended third party tools <c-api-tools>`
offer both simpler and more sophisticated approaches to creating C ... | Writing C is hard; are there any alternatives? ----------------------------------------------
There are a number of alternatives to writing your own C extensions, depending
on what you're trying to do. :ref:`Recommended third party tools <c-api-tools>`
offer both simpler and more sophisticated approaches to creating C ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
98451242-376d-4abd-99cc-66c514cac55a | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,607 | supabase-export-v2 | 5ea1f1a03b039160 | statement or you didn't close your parentheses or triple string quotes), but it gives you a syntax error message immediately when the input is invalid.
In Python you can use the :mod:`codeop` module, which approximates the parser's
behavior sufficiently. IDLE uses this, for example. | trusted_official_docs | CPython Docs | statement or you didn't close your parentheses or triple string quotes), but it gives you a syntax error message immediately when the input is invalid.
In Python you can use the :mod:`codeop` module, which approximates the parser's
behavior sufficiently. IDLE uses this, for example. | statement or you didn't close your parentheses or triple string quotes), but it gives you a syntax error message immediately when the input is invalid.
In Python you can use the :mod:`codeop` module, which approximates the parser's
behavior sufficiently. IDLE uses this, for example. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9aea7462-20b0-4870-85a5-5825083c7464 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,601 | supabase-export-v2 | f5e28493e4484cf4 | run myscript.py gdb) continue # repeat until your extension is loaded gdb) finish # so that your extension is loaded gdb) br myfunction.c:50 gdb) continue
I want to compile a Python module on my Linux system, but some files are missing. Why? ------------------------------------------------------------------------------... | trusted_official_docs | CPython Docs | run myscript.py gdb) continue # repeat until your extension is loaded gdb) finish # so that your extension is loaded gdb) br myfunction.c:50 gdb) continue
I want to compile a Python module on my Linux system, but some files are missing. Why? ------------------------------------------------------------------------------... | run myscript.py gdb) continue # repeat until your extension is loaded gdb) finish # so that your extension is loaded gdb) br myfunction.c:50 gdb) continue
I want to compile a Python module on my Linux system, but some files are missing. Why? ------------------------------------------------------------------------------... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9d4905e6-e272-4d5f-b1fd-eb5430b69fc9 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,558 | supabase-export-v2 | 2a9f11480f468ea0 | How can I evaluate an arbitrary Python expression from C? ---------------------------------------------------------
Call the function :c:func:`PyRun_String` from the previous question with the
start symbol :c:data:`Py_eval_input`; it parses an expression, evaluates it and
returns its value. | trusted_official_docs | CPython Docs | How can I evaluate an arbitrary Python expression from C? ---------------------------------------------------------
Call the function :c:func:`PyRun_String` from the previous question with the
start symbol :c:data:`Py_eval_input`; it parses an expression, evaluates it and
returns its value. | How can I evaluate an arbitrary Python expression from C? ---------------------------------------------------------
Call the function :c:func:`PyRun_String` from the previous question with the
start symbol :c:data:`Py_eval_input`; it parses an expression, evaluates it and
returns its value. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9e42aa54-7e35-486b-bb12-df87889b5d83 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,548 | supabase-export-v2 | e4ee01c24a592730 | Can I create my own functions in C? -----------------------------------
Yes, you can create built-in modules containing functions, variables, exceptions
and even new types in C. This is explained in the document
:ref:`extending-index`. | trusted_official_docs | CPython Docs | Can I create my own functions in C? -----------------------------------
Yes, you can create built-in modules containing functions, variables, exceptions
and even new types in C. This is explained in the document
:ref:`extending-index`. | Can I create my own functions in C? -----------------------------------
Yes, you can create built-in modules containing functions, variables, exceptions
and even new types in C. This is explained in the document
:ref:`extending-index`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a70b96a4-57aa-4ca0-bde1-968843f4cbfc | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,613 | supabase-export-v2 | 4d3f1878ae86449a | Yes, you can inherit from built-in classes such as :class:`int`, :class:`list`, :class:`dict`, etc.
The Boost Python Library (BPL, https://www.boost.org/libs/python/doc/index.html)
provides a way of doing this from C++ (i.e. you can inherit from an extension
class written in C++ using the BPL). | trusted_official_docs | CPython Docs | Yes, you can inherit from built-in classes such as :class:`int`, :class:`list`, :class:`dict`, etc.
The Boost Python Library (BPL, https://www.boost.org/libs/python/doc/index.html)
provides a way of doing this from C++ (i.e. you can inherit from an extension
class written in C++ using the BPL). | Yes, you can inherit from built-in classes such as :class:`int`, :class:`list`, :class:`dict`, etc.
The Boost Python Library (BPL, https://www.boost.org/libs/python/doc/index.html)
provides a way of doing this from C++ (i.e. you can inherit from an extension
class written in C++ using the BPL). | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a945ce95-e7d1-4e9f-9d71-64044c791e99 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,608 | supabase-export-v2 | dbbf1a09e81da15e | In Python you can use the :mod:`codeop` module, which approximates the parser's behavior sufficiently. IDLE uses this, for example.
The easiest way to do it in C is to call :c:func:`PyRun_InteractiveLoop` (perhaps
in a separate thread) and let the Python interpreter handle the input for
you. You can also set the :c:fun... | trusted_official_docs | CPython Docs | In Python you can use the :mod:`codeop` module, which approximates the parser's behavior sufficiently. IDLE uses this, for example.
The easiest way to do it in C is to call :c:func:`PyRun_InteractiveLoop` (perhaps
in a separate thread) and let the Python interpreter handle the input for
you. You can also set the :c:fun... | In Python you can use the :mod:`codeop` module, which approximates the parser's behavior sufficiently. IDLE uses this, for example.
The easiest way to do it in C is to call :c:func:`PyRun_InteractiveLoop` (perhaps
in a separate thread) and let the Python interpreter handle the input for
you. You can also set the :c:fun... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b6e7f152-0ff5-4d30-b164-583e29a6f01f | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,560 | supabase-export-v2 | 489fce913d8a3205 | How do I extract C values from a Python object? -----------------------------------------------
That depends on the object's type. If it's a tuple, :c:func:`PyTuple_Size`
returns its length and :c:func:`PyTuple_GetItem` returns the item at a specified
index. Lists have similar functions, :c:func:`PyList_Size` and
:c:fu... | trusted_official_docs | CPython Docs | How do I extract C values from a Python object? -----------------------------------------------
That depends on the object's type. If it's a tuple, :c:func:`PyTuple_Size`
returns its length and :c:func:`PyTuple_GetItem` returns the item at a specified
index. Lists have similar functions, :c:func:`PyList_Size` and
:c:fu... | How do I extract C values from a Python object? -----------------------------------------------
That depends on the object's type. If it's a tuple, :c:func:`PyTuple_Size`
returns its length and :c:func:`PyTuple_GetItem` returns the item at a specified
index. Lists have similar functions, :c:func:`PyList_Size` and
:c:fu... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c2720050-4dc9-42f4-9a75-8cb0f8f338ea | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,572 | supabase-export-v2 | 8e0460f2df4a2d57 | res = PyObject_CallMethod(f, "seek", "(ii)", 10, 0); if (res == NULL) { ... an exception occurred ... } else { Py_DECREF(res); }
Note that since :c:func:`PyObject_CallObject` *always* wants a tuple for the
argument list, to call a function without arguments, pass "()" for the format,
and to call a function with one arg... | trusted_official_docs | CPython Docs | res = PyObject_CallMethod(f, "seek", "(ii)", 10, 0); if (res == NULL) { ... an exception occurred ... } else { Py_DECREF(res); }
Note that since :c:func:`PyObject_CallObject` *always* wants a tuple for the
argument list, to call a function without arguments, pass "()" for the format,
and to call a function with one arg... | res = PyObject_CallMethod(f, "seek", "(ii)", 10, 0); if (res == NULL) { ... an exception occurred ... } else { Py_DECREF(res); }
Note that since :c:func:`PyObject_CallObject` *always* wants a tuple for the
argument list, to call a function without arguments, pass "()" for the format,
and to call a function with one arg... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c5b15cc7-3cd4-4c83-b345-b507a98275c7 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,567 | supabase-export-v2 | e4f33436b7e6de81 | How do I call an object's method from C? ----------------------------------------
The :c:func:`PyObject_CallMethod` function can be used to call an arbitrary
method of an object. The parameters are the object, the name of the method to
call, a format string like that used with :c:func:`Py_BuildValue`, and the
argument ... | trusted_official_docs | CPython Docs | How do I call an object's method from C? ----------------------------------------
The :c:func:`PyObject_CallMethod` function can be used to call an arbitrary
method of an object. The parameters are the object, the name of the method to
call, a format string like that used with :c:func:`Py_BuildValue`, and the
argument ... | How do I call an object's method from C? ----------------------------------------
The :c:func:`PyObject_CallMethod` function can be used to call an arbitrary
method of an object. The parameters are the object, the name of the method to
call, a format string like that used with :c:func:`Py_BuildValue`, and the
argument ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c616e8f1-31bc-4d50-9532-8dec869efd7d | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,564 | supabase-export-v2 | 09c665ccb32ed66c | using calls like :c:func:`PySequence_Length`, :c:func:`PySequence_GetItem`, etc. as well as many other useful protocols such as numbers (:c:func:`PyNumber_Index` et al.) and mappings in the PyMapping APIs.
How do I use Py_BuildValue() to create a tuple of arbitrary length? ----------------------------------------------... | trusted_official_docs | CPython Docs | using calls like :c:func:`PySequence_Length`, :c:func:`PySequence_GetItem`, etc. as well as many other useful protocols such as numbers (:c:func:`PyNumber_Index` et al.) and mappings in the PyMapping APIs.
How do I use Py_BuildValue() to create a tuple of arbitrary length? ----------------------------------------------... | using calls like :c:func:`PySequence_Length`, :c:func:`PySequence_GetItem`, etc. as well as many other useful protocols such as numbers (:c:func:`PyNumber_Index` et al.) and mappings in the PyMapping APIs.
How do I use Py_BuildValue() to create a tuple of arbitrary length? ----------------------------------------------... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c859219b-5657-4b4a-91c2-fb943c43a9c2 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,602 | supabase-export-v2 | 30a31d6ffe304b03 | I want to compile a Python module on my Linux system, but some files are missing. Why? --------------------------------------------------------------------------------------
Most packaged versions of Python omit some files
required for compiling Python extensions. | trusted_official_docs | CPython Docs | I want to compile a Python module on my Linux system, but some files are missing. Why? --------------------------------------------------------------------------------------
Most packaged versions of Python omit some files
required for compiling Python extensions. | I want to compile a Python module on my Linux system, but some files are missing. Why? --------------------------------------------------------------------------------------
Most packaged versions of Python omit some files
required for compiling Python extensions. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
de552af5-7e29-42a5-9a7e-5674cbd4b421 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,590 | supabase-export-v2 | 9292e554228714b6 | C and C++ -- so the strategy of building a new Python type around a C structure (pointer) type will also work for C++ objects.
For C++ libraries, see :ref:`c-wrapper-software`. | trusted_official_docs | CPython Docs | C and C++ -- so the strategy of building a new Python type around a C structure (pointer) type will also work for C++ objects.
For C++ libraries, see :ref:`c-wrapper-software`. | C and C++ -- so the strategy of building a new Python type around a C structure (pointer) type will also work for C++ objects.
For C++ libraries, see :ref:`c-wrapper-software`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e3569427-0ab6-43e4-8ac9-9a5ff57bb893 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,551 | supabase-export-v2 | d7412784e7e008cb | Can I create my own functions in C++? -------------------------------------
Yes, using the C compatibility features found in C++. Place ``extern "C" {
... }`` around the Python include files and put ``extern "C"`` before each
function that is going to be called by the Python interpreter. Global or static
C++ objects wi... | trusted_official_docs | CPython Docs | Can I create my own functions in C++? -------------------------------------
Yes, using the C compatibility features found in C++. Place ``extern "C" {
... }`` around the Python include files and put ``extern "C"`` before each
function that is going to be called by the Python interpreter. Global or static
C++ objects wi... | Can I create my own functions in C++? -------------------------------------
Yes, using the C compatibility features found in C++. Place ``extern "C" {
... }`` around the Python include files and put ``extern "C"`` before each
function that is going to be called by the Python interpreter. Global or static
C++ objects wi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
e4b5bcd4-b317-4da4-8510-2197cf7dc982 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,589 | supabase-export-v2 | 716c10eac9b3efcc | How do I interface to C++ objects from Python? ----------------------------------------------
Depending on your requirements, there are many approaches. To do this manually,
begin by reading :ref:`the "Extending and Embedding" document
<extending-index>`. Realize that for the Python run-time system, there isn't a
whole... | trusted_official_docs | CPython Docs | How do I interface to C++ objects from Python? ----------------------------------------------
Depending on your requirements, there are many approaches. To do this manually,
begin by reading :ref:`the "Extending and Embedding" document
<extending-index>`. Realize that for the Python run-time system, there isn't a
whole... | How do I interface to C++ objects from Python? ----------------------------------------------
Depending on your requirements, there are many approaches. To do this manually,
begin by reading :ref:`the "Extending and Embedding" document
<extending-index>`. Realize that for the Python run-time system, there isn't a
whole... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f1eead1f-537b-4e40-ab3b-9ff446efd604 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,609 | supabase-export-v2 | 03d70e43a3d18f5c | handle the input for you. You can also set the :c:func:`PyOS_ReadlineFunctionPointer` to point at your custom input function. See ``Modules/readline.c`` and ``Parser/myreadline.c`` for more hints.
How do I find undefined g++ symbols __builtin_new or __pure_virtual? ------------------------------------------------------... | trusted_official_docs | CPython Docs | handle the input for you. You can also set the :c:func:`PyOS_ReadlineFunctionPointer` to point at your custom input function. See ``Modules/readline.c`` and ``Parser/myreadline.c`` for more hints.
How do I find undefined g++ symbols __builtin_new or __pure_virtual? ------------------------------------------------------... | handle the input for you. You can also set the :c:func:`PyOS_ReadlineFunctionPointer` to point at your custom input function. See ``Modules/readline.c`` and ``Parser/myreadline.c`` for more hints.
How do I find undefined g++ symbols __builtin_new or __pure_virtual? ------------------------------------------------------... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
f2e46b5c-7881-49f6-a09b-c3fd370db5ef | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,556 | supabase-export-v2 | 2a46b48f7d4d01b0 | How can I execute arbitrary Python statements from C? -----------------------------------------------------
The highest-level function to do this is :c:func:`PyRun_SimpleString` which takes
a single string argument to be executed in the context of the module
``__main__`` and returns ``0`` for success and ``-1`` when an... | trusted_official_docs | CPython Docs | How can I execute arbitrary Python statements from C? -----------------------------------------------------
The highest-level function to do this is :c:func:`PyRun_SimpleString` which takes
a single string argument to be executed in the context of the module
``__main__`` and returns ``0`` for success and ``-1`` when an... | How can I execute arbitrary Python statements from C? -----------------------------------------------------
The highest-level function to do this is :c:func:`PyRun_SimpleString` which takes
a single string argument to be executed in the context of the module
``__main__`` and returns ``0`` for success and ``-1`` when an... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
fc1cf00f-c8c1-4856-aceb-8e8a8d65e013 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,612 | supabase-export-v2 | 21ca6740969f8918 | Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? ----------------------------------------------------------------------------------------------------------------
Yes, you can inherit from built-in classes such as :class:`int`, :class:`list`,
:class:`dict`,... | trusted_official_docs | CPython Docs | Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? ----------------------------------------------------------------------------------------------------------------
Yes, you can inherit from built-in classes such as :class:`int`, :class:`list`,
:class:`dict`,... | Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? ----------------------------------------------------------------------------------------------------------------
Yes, you can inherit from built-in classes such as :class:`int`, :class:`list`,
:class:`dict`,... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ff0a7a71-5037-476d-8e52-2874d0daa935 | CPython Docs | file://datasets/cpython/Doc/faq/extending.rst | unknown | 2190b383-2346-4e34-b1b0-6051d612a16d | 1,584 | supabase-export-v2 | 57da2648d04d1ca8 | module = PyImport_ImportModule("<modulename>");
If the module hasn't been imported yet (i.e. it is not yet present in
:data:`sys.modules`), this initializes the module; otherwise it simply returns
the value of ``sys.modules["<modulename>"]``. Note that it doesn't enter the
module into any namespace -- it only ensures i... | trusted_official_docs | CPython Docs | module = PyImport_ImportModule("<modulename>");
If the module hasn't been imported yet (i.e. it is not yet present in
:data:`sys.modules`), this initializes the module; otherwise it simply returns
the value of ``sys.modules["<modulename>"]``. Note that it doesn't enter the
module into any namespace -- it only ensures i... | module = PyImport_ImportModule("<modulename>");
If the module hasn't been imported yet (i.e. it is not yet present in
:data:`sys.modules`), this initializes the module; otherwise it simply returns
the value of ``sys.modules["<modulename>"]``. Note that it doesn't enter the
module into any namespace -- it only ensures i... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0298b2bb-7a25-423e-ac10-0d3f7eee7252 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 2,065 | supabase-export-v2 | 280759f669c8de4f | However, identity tests can *only* be substituted for equality tests when object identity is assured. Generally, there are three circumstances where identity is guaranteed:
1) Assignments create new names but do not change object identity. After the
assignment ``new = old``, it is guaranteed that ``new is old``. | trusted_official_docs | CPython Docs | However, identity tests can *only* be substituted for equality tests when object identity is assured. Generally, there are three circumstances where identity is guaranteed:
1) Assignments create new names but do not change object identity. After the
assignment ``new = old``, it is guaranteed that ``new is old``. | However, identity tests can *only* be substituted for equality tests when object identity is assured. Generally, there are three circumstances where identity is guaranteed:
1) Assignments create new names but do not change object identity. After the
assignment ``new = old``, it is guaranteed that ``new is old``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
02b9a760-8434-4ced-9364-61da20bca81f | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,686 | supabase-export-v2 | 8be3d51c49201532 | import is at the top level. That's because names in the 1st are not yet available, because the first module is busy importing the 2nd.
In this case, if the second module is only used in one function, then the import
can easily be moved into that function. By the time the import is called, the
first module will have fin... | trusted_official_docs | CPython Docs | import is at the top level. That's because names in the 1st are not yet available, because the first module is busy importing the 2nd.
In this case, if the second module is only used in one function, then the import
can easily be moved into that function. By the time the import is called, the
first module will have fin... | import is at the top level. That's because names in the 1st are not yet available, because the first module is busy importing the 2nd.
In this case, if the second module is only used in one function, then the import
can easily be moved into that function. By the time the import is called, the
first module will have fin... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
02d81a4c-48b0-4593-bfb7-7c74a87164d0 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,963 | supabase-export-v2 | 76f65ee379d5fca1 | elements of a list by a metric which maps each element to its "sort value". In Python, use the ``key`` argument for the :meth:`list.sort` method::
Isorted = L[:]
Isorted.sort(key=lambda s: int(s[10:15])) | trusted_official_docs | CPython Docs | elements of a list by a metric which maps each element to its "sort value". In Python, use the ``key`` argument for the :meth:`list.sort` method::
Isorted = L[:]
Isorted.sort(key=lambda s: int(s[10:15])) | elements of a list by a metric which maps each element to its "sort value". In Python, use the ``key`` argument for the :meth:`list.sort` method::
Isorted = L[:]
Isorted.sort(key=lambda s: int(s[10:15])) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
05e2599a-2c3a-41a6-9725-56b6a7e81ed0 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,731 | supabase-export-v2 | b78b57d5bf5e9d60 | 1) By returning a tuple of the results::
>>> def func1(a, b):
... a = 'new-value' # a and b are local names
... b = b + 1 # assigned to new objects
... return a, b # return new values
... >>> x, y = 'old-value', 99
>>> func1(x, y)
('new-value', 100) | trusted_official_docs | CPython Docs | 1) By returning a tuple of the results::
>>> def func1(a, b):
... a = 'new-value' # a and b are local names
... b = b + 1 # assigned to new objects
... return a, b # return new values
... >>> x, y = 'old-value', 99
>>> func1(x, y)
('new-value', 100) | 1) By returning a tuple of the results::
>>> def func1(a, b):
... a = 'new-value' # a and b are local names
... b = b + 1 # assigned to new objects
... return a, b # return new values
... >>> x, y = 'old-value', 99
>>> func1(x, y)
('new-value', 100) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
068b0b7e-5b21-4547-bf76-69e9cfe1e020 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,881 | supabase-export-v2 | c6a362e443d34e81 | To accumulate many :class:`str` objects, the recommended idiom is to place them into a list and call :meth:`str.join` at the end::
chunks = []
for s in my_strings:
chunks.append(s)
result = ''.join(chunks) | trusted_official_docs | CPython Docs | To accumulate many :class:`str` objects, the recommended idiom is to place them into a list and call :meth:`str.join` at the end::
chunks = []
for s in my_strings:
chunks.append(s)
result = ''.join(chunks) | To accumulate many :class:`str` objects, the recommended idiom is to place them into a list and call :meth:`str.join` at the end::
chunks = []
for s in my_strings:
chunks.append(s)
result = ''.join(chunks) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
06ea51ca-b45f-47f9-bdfc-9ed0b2be93be | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,736 | supabase-export-v2 | 780db231116d84c4 | mutable list ... a[1] = a[1] + 1 # changes a shared object ... >>> args = ['old-value', 99] >>> func2(args) >>> args ['new-value', 100]
4) By passing in a dictionary that gets mutated:: | trusted_official_docs | CPython Docs | mutable list ... a[1] = a[1] + 1 # changes a shared object ... >>> args = ['old-value', 99] >>> func2(args) >>> args ['new-value', 100]
4) By passing in a dictionary that gets mutated:: | mutable list ... a[1] = a[1] + 1 # changes a shared object ... >>> args = ['old-value', 99] >>> func2(args) >>> args ['new-value', 100]
4) By passing in a dictionary that gets mutated:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
07cc22e9-f6fa-468f-a126-7d0cadb575d3 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,684 | supabase-export-v2 | 9a5916e679cf5266 | as :mod:`sys`, :mod:`os`, :mod:`argparse`, :mod:`re` 2. third-party library modules (anything installed in Python's site-packages directory) -- such as :pypi:`dateutil`, :pypi:`requests`, :pypi:`tzdata` 3. locally developed modules
It is sometimes necessary to move imports to a function or class to avoid
problems with ... | trusted_official_docs | CPython Docs | as :mod:`sys`, :mod:`os`, :mod:`argparse`, :mod:`re` 2. third-party library modules (anything installed in Python's site-packages directory) -- such as :pypi:`dateutil`, :pypi:`requests`, :pypi:`tzdata` 3. locally developed modules
It is sometimes necessary to move imports to a function or class to avoid
problems with ... | as :mod:`sys`, :mod:`os`, :mod:`argparse`, :mod:`re` 2. third-party library modules (anything installed in Python's site-packages directory) -- such as :pypi:`dateutil`, :pypi:`requests`, :pypi:`tzdata` 3. locally developed modules
It is sometimes necessary to move imports to a function or class to avoid
problems with ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
07e4b699-4969-4715-a2b0-9cb094adc6a8 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,687 | supabase-export-v2 | 5cfc2d211040f574 | into that function. By the time the import is called, the first module will have finished initializing, and the second module can do its import.
It may also be necessary to move imports out of the top level of code if some of
the modules are platform-specific. In that case, it may not even be possible to
import all of ... | trusted_official_docs | CPython Docs | into that function. By the time the import is called, the first module will have finished initializing, and the second module can do its import.
It may also be necessary to move imports out of the top level of code if some of
the modules are platform-specific. In that case, it may not even be possible to
import all of ... | into that function. By the time the import is called, the first module will have finished initializing, and the second module can do its import.
It may also be necessary to move imports out of the top level of code if some of
the modules are platform-specific. In that case, it may not even be possible to
import all of ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
08b57173-6ebc-4727-b5e3-c7708b570073 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,619 | supabase-export-v2 | 93ad034668b6009d | Several debuggers for Python are described below, and the built-in function :func:`breakpoint` allows you to drop into any of them.
The pdb module is a simple but adequate console-mode debugger for Python. It is
part of the standard Python library, and is :mod:`documented in the Library
Reference Manual <pdb>`. You can... | trusted_official_docs | CPython Docs | Several debuggers for Python are described below, and the built-in function :func:`breakpoint` allows you to drop into any of them.
The pdb module is a simple but adequate console-mode debugger for Python. It is
part of the standard Python library, and is :mod:`documented in the Library
Reference Manual <pdb>`. You can... | Several debuggers for Python are described below, and the built-in function :func:`breakpoint` allows you to drop into any of them.
The pdb module is a simple but adequate console-mode debugger for Python. It is
part of the standard Python library, and is :mod:`documented in the Library
Reference Manual <pdb>`. You can... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
08e82bce-dda5-4cbc-9804-99694b5e5b6f | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,691 | supabase-export-v2 | eff5ecad2bf4886d | This type of bug commonly bites neophyte programmers. Consider this function::
def foo(mydict={}): # Danger: shared reference to one dict for all calls
... compute something ... mydict[key] = value
return mydict | trusted_official_docs | CPython Docs | This type of bug commonly bites neophyte programmers. Consider this function::
def foo(mydict={}): # Danger: shared reference to one dict for all calls
... compute something ... mydict[key] = value
return mydict | This type of bug commonly bites neophyte programmers. Consider this function::
def foo(mydict={}): # Danger: shared reference to one dict for all calls
... compute something ... mydict[key] = value
return mydict | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
09494e3d-2a33-40de-85ae-0d64ebe34213 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,673 | supabase-export-v2 | a2ba6655709daca2 | How do I share global variables across modules? ------------------------------------------------
The canonical way to share information across modules within a single program is
to create a special module (often called config or cfg). Just import the config
module in all modules of your application; the module then bec... | trusted_official_docs | CPython Docs | How do I share global variables across modules? ------------------------------------------------
The canonical way to share information across modules within a single program is
to create a special module (often called config or cfg). Just import the config
module in all modules of your application; the module then bec... | How do I share global variables across modules? ------------------------------------------------
The canonical way to share information across modules within a single program is
to create a special module (often called config or cfg). Just import the config
module in all modules of your application; the module then bec... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
09c957f6-d9d1-4f4f-86ba-31a23f9523b2 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 2,059 | supabase-export-v2 | 7002bf832765979c | execution of the ``id()`` call. To be sure that objects whose id you want to examine are still alive, create another reference to the object:
>>> a = 1000; b = 2000
>>> id(a) # doctest: +SKIP
13901272
>>> id(b) # doctest: +SKIP
13891296 | trusted_official_docs | CPython Docs | execution of the ``id()`` call. To be sure that objects whose id you want to examine are still alive, create another reference to the object:
>>> a = 1000; b = 2000
>>> id(a) # doctest: +SKIP
13901272
>>> id(b) # doctest: +SKIP
13891296 | execution of the ``id()`` call. To be sure that objects whose id you want to examine are still alive, create another reference to the object:
>>> a = 1000; b = 2000
>>> id(a) # doctest: +SKIP
13901272
>>> id(b) # doctest: +SKIP
13891296 | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0a974128-b4a6-49c6-8543-d2f55e2727ca | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,884 | supabase-export-v2 | 3ac956671fb0e232 | To accumulate many :class:`bytes` objects, the recommended idiom is to extend a :class:`bytearray` object using in-place concatenation (the ``+=`` operator)::
result = bytearray()
for b in my_bytes_objects:
result += b | trusted_official_docs | CPython Docs | To accumulate many :class:`bytes` objects, the recommended idiom is to extend a :class:`bytearray` object using in-place concatenation (the ``+=`` operator)::
result = bytearray()
for b in my_bytes_objects:
result += b | To accumulate many :class:`bytes` objects, the recommended idiom is to extend a :class:`bytearray` object using in-place concatenation (the ``+=`` operator)::
result = bytearray()
for b in my_bytes_objects:
result += b | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0b0780b7-4161-4f54-8b83-b6a82817faf4 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,771 | supabase-export-v2 | 3309cb080dd6c476 | the names" of particular values. Unless you are deliberately writing introspective programs, this is usually an indication that a change of approach might be beneficial.
In comp.lang.python, Fredrik Lundh once gave an excellent analogy in answer to
this question: | trusted_official_docs | CPython Docs | the names" of particular values. Unless you are deliberately writing introspective programs, this is usually an indication that a change of approach might be beneficial.
In comp.lang.python, Fredrik Lundh once gave an excellent analogy in answer to
this question: | the names" of particular values. Unless you are deliberately writing introspective programs, this is usually an indication that a change of approach might be beneficial.
In comp.lang.python, Fredrik Lundh once gave an excellent analogy in answer to
this question: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0ba80617-c080-4c6f-bdc2-7e347324e6c4 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,668 | supabase-export-v2 | 2293e74444507a2a | this, you need to save the values in variables local to the lambdas, so that they don't rely on the value of the global ``x``::
>>> squares = []
>>> for x in range(5):
... squares.append(lambda n=x: n**2) | trusted_official_docs | CPython Docs | this, you need to save the values in variables local to the lambdas, so that they don't rely on the value of the global ``x``::
>>> squares = []
>>> for x in range(5):
... squares.append(lambda n=x: n**2) | this, you need to save the values in variables local to the lambdas, so that they don't rely on the value of the global ``x``::
>>> squares = []
>>> for x in range(5):
... squares.append(lambda n=x: n**2) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0cdcd486-ad7d-43d7-b941-edb572818974 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 2,074 | supabase-export-v2 | 6dc2ea3af011b842 | In the standard library code, you will see several common patterns for correctly using identity tests:
1) As recommended by :pep:`8`, an identity test is the preferred way to check
for ``None``. This reads like plain English in code and avoids confusion
with other objects that may have boolean values that evaluate to... | trusted_official_docs | CPython Docs | In the standard library code, you will see several common patterns for correctly using identity tests:
1) As recommended by :pep:`8`, an identity test is the preferred way to check
for ``None``. This reads like plain English in code and avoids confusion
with other objects that may have boolean values that evaluate to... | In the standard library code, you will see several common patterns for correctly using identity tests:
1) As recommended by :pep:`8`, an identity test is the preferred way to check
for ``None``. This reads like plain English in code and avoids confusion
with other objects that may have boolean values that evaluate to... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0dc1f447-f230-4193-813f-aee01e688753 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,797 | supabase-export-v2 | f5343e6a3c28dfbc | arguments are mapped to parameters based solely on their position. For example, :func:`divmod` is a function that accepts positional-only parameters. Its documentation looks like this::
>>> help(divmod)
Help on built-in function divmod in module builtins: | trusted_official_docs | CPython Docs | arguments are mapped to parameters based solely on their position. For example, :func:`divmod` is a function that accepts positional-only parameters. Its documentation looks like this::
>>> help(divmod)
Help on built-in function divmod in module builtins: | arguments are mapped to parameters based solely on their position. For example, :func:`divmod` is a function that accepts positional-only parameters. Its documentation looks like this::
>>> help(divmod)
Help on built-in function divmod in module builtins: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0ed78f09-0e42-4db0-a1fa-0a72a7d1d752 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 2,068 | supabase-export-v2 | 6f06c01924b9317a | object can exist. After the assignments ``a = None`` and ``b = None``, it is guaranteed that ``a is b`` because ``None`` is a singleton.
In most other circumstances, identity tests are inadvisable and equality tests
are preferred. In particular, identity tests should not be used to check
constants such as :class:`int` ... | trusted_official_docs | CPython Docs | object can exist. After the assignments ``a = None`` and ``b = None``, it is guaranteed that ``a is b`` because ``None`` is a singleton.
In most other circumstances, identity tests are inadvisable and equality tests
are preferred. In particular, identity tests should not be used to check
constants such as :class:`int` ... | object can exist. After the assignments ``a = None`` and ``b = None``, it is guaranteed that ``a is b`` because ``None`` is a singleton.
In most other circumstances, identity tests are inadvisable and equality tests
are preferred. In particular, identity tests should not be used to check
constants such as :class:`int` ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0f6fcd78-db10-4569-b2a4-5ccbb7cf861a | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 2,057 | supabase-export-v2 | 18a3980c5fffbcbc | an object is deleted from memory, the next freshly created object is allocated at the same position in memory. This is illustrated by this example:
>>> id(1000) # doctest: +SKIP
13901272
>>> id(2000) # doctest: +SKIP
13901272 | trusted_official_docs | CPython Docs | an object is deleted from memory, the next freshly created object is allocated at the same position in memory. This is illustrated by this example:
>>> id(1000) # doctest: +SKIP
13901272
>>> id(2000) # doctest: +SKIP
13901272 | an object is deleted from memory, the next freshly created object is allocated at the same position in memory. This is illustrated by this example:
>>> id(1000) # doctest: +SKIP
13901272
>>> id(2000) # doctest: +SKIP
13901272 | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
0f974fa4-dffe-47d6-92c0-e8278818b4ff | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,739 | supabase-export-v2 | 73e6e582792b4124 | 5) Or bundle up values in a class instance::
>>> class Namespace:
... def __init__(self, /, **args):
... for key, value in args.items():
... setattr(self, key, value)
... >>> def func4(args):
... args.a = 'new-value' # args is a mutable Namespace
... args.b = args.b + 1 # change object in-place
... >>> args = Na... | trusted_official_docs | CPython Docs | 5) Or bundle up values in a class instance::
>>> class Namespace:
... def __init__(self, /, **args):
... for key, value in args.items():
... setattr(self, key, value)
... >>> def func4(args):
... args.a = 'new-value' # args is a mutable Namespace
... args.b = args.b + 1 # change object in-place
... >>> args = Na... | 5) Or bundle up values in a class instance::
>>> class Namespace:
... def __init__(self, /, **args):
... for key, value in args.items():
... setattr(self, key, value)
... >>> def func4(args):
... args.a = 'new-value' # args is a mutable Namespace
... args.b = args.b + 1 # change object in-place
... >>> args = Na... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
100f3426-feae-4a84-9937-08dd66d26f35 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 2,094 | supabase-export-v2 | e56eb2df2c7856d9 | two principal tools for caching methods are :func:`functools.cached_property` and :func:`functools.lru_cache`. The former stores results at the instance level and the latter at the class level.
The ``cached_property`` approach only works with methods that do not take
any arguments. It does not create a reference to the... | trusted_official_docs | CPython Docs | two principal tools for caching methods are :func:`functools.cached_property` and :func:`functools.lru_cache`. The former stores results at the instance level and the latter at the class level.
The ``cached_property`` approach only works with methods that do not take
any arguments. It does not create a reference to the... | two principal tools for caching methods are :func:`functools.cached_property` and :func:`functools.lru_cache`. The former stores results at the instance level and the latter at the class level.
The ``cached_property`` approach only works with methods that do not take
any arguments. It does not create a reference to the... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1041726e-9d1a-4188-8f50-966a23208dc9 | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 2,028 | supabase-export-v2 | b8e9cdd48750b4fd | class C { C() { cout << "No arguments\n"; } C(int i) { cout << "Argument is " << i << "\n"; } }
In Python you have to write a single constructor that catches all cases using
default arguments. For example:: | trusted_official_docs | CPython Docs | class C { C() { cout << "No arguments\n"; } C(int i) { cout << "Argument is " << i << "\n"; } }
In Python you have to write a single constructor that catches all cases using
default arguments. For example:: | class C { C() { cout << "No arguments\n"; } C(int i) { cout << "Argument is " << i << "\n"; } }
In Python you have to write a single constructor that catches all cases using
default arguments. For example:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1089931c-215b-4da0-9cb7-984bb69e749c | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,932 | supabase-export-v2 | e44a36319377d6cb | Or, you can use an extension that provides a matrix datatype; `NumPy <https://numpy.org/>`_ is the best known.
How do I apply a method or function to a sequence of objects? ------------------------------------------------------------- | trusted_official_docs | CPython Docs | Or, you can use an extension that provides a matrix datatype; `NumPy <https://numpy.org/>`_ is the best known.
How do I apply a method or function to a sequence of objects? ------------------------------------------------------------- | Or, you can use an extension that provides a matrix datatype; `NumPy <https://numpy.org/>`_ is the best known.
How do I apply a method or function to a sequence of objects? ------------------------------------------------------------- | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
1255862d-d213-4022-aed8-cbd61a042f0f | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 2,003 | supabase-export-v2 | 378d7d1d643b0b37 | Alternatively, it is possible to set attributes by inserting entries into :attr:`self.__dict__ <object.__dict__>` directly.
How do I call a method defined in a base class from a derived class that extends it? ------------------------------------------------------------------------------------ | trusted_official_docs | CPython Docs | Alternatively, it is possible to set attributes by inserting entries into :attr:`self.__dict__ <object.__dict__>` directly.
How do I call a method defined in a base class from a derived class that extends it? ------------------------------------------------------------------------------------ | Alternatively, it is possible to set attributes by inserting entries into :attr:`self.__dict__ <object.__dict__>` directly.
How do I call a method defined in a base class from a derived class that extends it? ------------------------------------------------------------------------------------ | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
133c9247-bb2a-4b89-8cea-4ca06eb7ad2d | CPython Docs | file://datasets/cpython/Doc/faq/programming.rst | unknown | edda7b58-bd69-4060-9295-d9036b4690eb | 1,879 | supabase-export-v2 | 32ce0bc8bffbd14f | What is the most efficient way to concatenate many strings together? --------------------------------------------------------------------
:class:`str` and :class:`bytes` objects are immutable, therefore concatenating
many strings together is inefficient as each concatenation creates a new
object. In the general case, t... | trusted_official_docs | CPython Docs | What is the most efficient way to concatenate many strings together? --------------------------------------------------------------------
:class:`str` and :class:`bytes` objects are immutable, therefore concatenating
many strings together is inefficient as each concatenation creates a new
object. In the general case, t... | What is the most efficient way to concatenate many strings together? --------------------------------------------------------------------
:class:`str` and :class:`bytes` objects are immutable, therefore concatenating
many strings together is inefficient as each concatenation creates a new
object. In the general case, t... | python, official-docs, cpython, P0 | Local_Trusted_Corpus |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.