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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7f37eb34-dd1f-41e5-b948-d9e375213bbf | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,203 | supabase-export-v2 | c17a1f3a33228d92 | Functions are accessed as attributes of dll objects::
>>> libc.printf
<_FuncPtr object at 0x...>
>>> print(windll.kernel32.GetModuleHandleA) # doctest: +WINDOWS
<_FuncPtr object at 0x...>
>>> print(windll.kernel32.MyOwnFunction) # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in <mo... | trusted_official_docs | CPython Docs | Functions are accessed as attributes of dll objects::
>>> libc.printf
<_FuncPtr object at 0x...>
>>> print(windll.kernel32.GetModuleHandleA) # doctest: +WINDOWS
<_FuncPtr object at 0x...>
>>> print(windll.kernel32.MyOwnFunction) # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in <mo... | Functions are accessed as attributes of dll objects::
>>> libc.printf
<_FuncPtr object at 0x...>
>>> print(windll.kernel32.GetModuleHandleA) # doctest: +WINDOWS
<_FuncPtr object at 0x...>
>>> print(windll.kernel32.MyOwnFunction) # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in <mo... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
863b3e36-d9c4-41b1-8053-427dd9897d51 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,287 | supabase-export-v2 | 3a16c49cf41eefaf | call will be used as the result of your function call. This is useful to check for error return values and automatically raise an exception::
>>> GetModuleHandle = windll.kernel32.GetModuleHandleA # doctest: +WINDOWS
>>> def ValidHandle(value):
... if value == 0:
... raise WinError()
... return value
... >>>
>>> ... | trusted_official_docs | CPython Docs | call will be used as the result of your function call. This is useful to check for error return values and automatically raise an exception::
>>> GetModuleHandle = windll.kernel32.GetModuleHandleA # doctest: +WINDOWS
>>> def ValidHandle(value):
... if value == 0:
... raise WinError()
... return value
... >>>
>>> ... | call will be used as the result of your function call. This is useful to check for error return values and automatically raise an exception::
>>> GetModuleHandle = windll.kernel32.GetModuleHandleA # doctest: +WINDOWS
>>> def ValidHandle(value):
... if value == 0:
... raise WinError()
... return value
... >>>
>>> ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
86c5784a-e731-4e2a-ae05-99090ff8ca30 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,240 | supabase-export-v2 | 848969bf8e46408a | >>> i = c_int(42) >>> print(i) c_long(42) >>> print(i.value) 42 >>> i.value = -99 >>> print(i.value) -99 >>>
Assigning a new value to instances of the pointer types :class:`c_char_p`,
:class:`c_wchar_p`, and :class:`c_void_p` changes the *memory location* they
point to, *not the contents* of the memory block (of course... | trusted_official_docs | CPython Docs | >>> i = c_int(42) >>> print(i) c_long(42) >>> print(i.value) 42 >>> i.value = -99 >>> print(i.value) -99 >>>
Assigning a new value to instances of the pointer types :class:`c_char_p`,
:class:`c_wchar_p`, and :class:`c_void_p` changes the *memory location* they
point to, *not the contents* of the memory block (of course... | >>> i = c_int(42) >>> print(i) c_long(42) >>> print(i.value) 42 >>> i.value = -99 >>> print(i.value) -99 >>>
Assigning a new value to instances of the pointer types :class:`c_char_p`,
:class:`c_wchar_p`, and :class:`c_void_p` changes the *memory location* they
point to, *not the contents* of the memory block (of course... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
87eaa622-d0c2-4381-b210-1ca9d924a536 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,467 | supabase-export-v2 | 9351907b1d76b755 | the value of the ctypes private copy, and the function :func:`ctypes.set_errno` changes the ctypes private copy to a new value and returns the former value.
The *use_last_error* parameter, when set to true, enables the same mechanism for
the Windows error code which is managed by the :func:`GetLastError` and
:func:`!... | trusted_official_docs | CPython Docs | the value of the ctypes private copy, and the function :func:`ctypes.set_errno` changes the ctypes private copy to a new value and returns the former value.
The *use_last_error* parameter, when set to true, enables the same mechanism for
the Windows error code which is managed by the :func:`GetLastError` and
:func:`!... | the value of the ctypes private copy, and the function :func:`ctypes.set_errno` changes the ctypes private copy to a new value and returns the former value.
The *use_last_error* parameter, when set to true, enables the same mechanism for
the Windows error code which is managed by the :func:`GetLastError` and
:func:`!... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
88f14b2e-2208-4e51-8118-73685d3ce1a8 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,282 | supabase-export-v2 | a58e99aa9ec568c2 | is a more advanced example, it uses the :func:`!strchr` function, which expects a string pointer and a char, and returns a pointer to a string::
>>> strchr = libc.strchr
>>> strchr(b"abcdef", ord("d")) # doctest: +SKIP
8059983
>>> strchr.restype = c_char_p # c_char_p is a pointer to a string
>>> strchr(b"abcdef", o... | trusted_official_docs | CPython Docs | is a more advanced example, it uses the :func:`!strchr` function, which expects a string pointer and a char, and returns a pointer to a string::
>>> strchr = libc.strchr
>>> strchr(b"abcdef", ord("d")) # doctest: +SKIP
8059983
>>> strchr.restype = c_char_p # c_char_p is a pointer to a string
>>> strchr(b"abcdef", o... | is a more advanced example, it uses the :func:`!strchr` function, which expects a string pointer and a char, and returns a pointer to a string::
>>> strchr = libc.strchr
>>> strchr(b"abcdef", ord("d")) # doctest: +SKIP
8059983
>>> strchr.restype = c_char_p # c_char_p is a pointer to a string
>>> strchr(b"abcdef", o... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
89d02318-564a-48da-8e08-dbd8c9b0c343 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,889 | supabase-export-v2 | 4244331c6d107972 | optional sequence that lists the names of unnamed (anonymous) fields. :attr:`_anonymous_` must be already defined when :attr:`_fields_` is assigned, otherwise it will have no effect.
The fields listed in this variable must be structure or union type fields. :mod:`!ctypes` will create descriptors in the structure type t... | trusted_official_docs | CPython Docs | optional sequence that lists the names of unnamed (anonymous) fields. :attr:`_anonymous_` must be already defined when :attr:`_fields_` is assigned, otherwise it will have no effect.
The fields listed in this variable must be structure or union type fields. :mod:`!ctypes` will create descriptors in the structure type t... | optional sequence that lists the names of unnamed (anonymous) fields. :attr:`_anonymous_` must be already defined when :attr:`_fields_` is assigned, otherwise it will have no effect.
The fields listed in this variable must be structure or union type fields. :mod:`!ctypes` will create descriptors in the structure type t... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8a200d5d-16ea-4d69-8b35-937ed0880e22 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,543 | supabase-export-v2 | 24e334cb33f6df96 | the library cannot be determined, ``None`` is returned. Notably, this will happen for recent versions of the VC runtime library, which are not directly loadable.
If you need to free memory, for example, allocated by an extension module
with a call to the ``free(void *)``, it is important that you use the
function in ... | trusted_official_docs | CPython Docs | the library cannot be determined, ``None`` is returned. Notably, this will happen for recent versions of the VC runtime library, which are not directly loadable.
If you need to free memory, for example, allocated by an extension module
with a call to the ``free(void *)``, it is important that you use the
function in ... | the library cannot be determined, ``None`` is returned. Notably, this will happen for recent versions of the VC runtime library, which are not directly loadable.
If you need to free memory, for example, allocated by an extension module
with a call to the ``free(void *)``, it is important that you use the
function in ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8b32fa62-eb41-4bdc-9841-347f8a5d9119 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,218 | supabase-export-v2 | ff1ed2f5edd69d26 | :exc:`ValueError` is raised when you call an ``stdcall`` function with the ``cdecl`` calling convention, or vice versa::
>>> cdll.kernel32.GetModuleHandleA(None) # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Procedure probably called with not enough arguments ... | trusted_official_docs | CPython Docs | :exc:`ValueError` is raised when you call an ``stdcall`` function with the ``cdecl`` calling convention, or vice versa::
>>> cdll.kernel32.GetModuleHandleA(None) # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Procedure probably called with not enough arguments ... | :exc:`ValueError` is raised when you call an ``stdcall`` function with the ``cdecl`` calling convention, or vice versa::
>>> cdll.kernel32.GetModuleHandleA(None) # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Procedure probably called with not enough arguments ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8c414900-f4ee-4c01-ac76-0f5ce0043960 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,694 | supabase-export-v2 | af6f2354d4eea7d7 | .. function:: resize(obj, size)
This function resizes the internal memory buffer of *obj*, which must be an
instance of a ctypes type. It is not possible to make the buffer smaller
than the native size of the objects type, as given by ``sizeof(type(obj))``,
but it is possible to enlarge the buffer. | trusted_official_docs | CPython Docs | .. function:: resize(obj, size)
This function resizes the internal memory buffer of *obj*, which must be an
instance of a ctypes type. It is not possible to make the buffer smaller
than the native size of the objects type, as given by ``sizeof(type(obj))``,
but it is possible to enlarge the buffer. | .. function:: resize(obj, size)
This function resizes the internal memory buffer of *obj*, which must be an
instance of a ctypes type. It is not possible to make the buffer smaller
than the native size of the objects type, as given by ``sizeof(type(obj))``,
but it is possible to enlarge the buffer. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8ce4bca7-2d45-4e2c-a4bf-e5bd90d9cefb | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,216 | supabase-export-v2 | 50333d5c7198a412 | Windows, you can call the ``GetModuleHandleA()`` function, which returns a win32 module handle (passing ``None`` as single argument to call it with a ``NULL`` pointer)::
>>> print(hex(windll.kernel32.GetModuleHandleA(None))) # doctest: +WINDOWS
0x1d000000
>>> | trusted_official_docs | CPython Docs | Windows, you can call the ``GetModuleHandleA()`` function, which returns a win32 module handle (passing ``None`` as single argument to call it with a ``NULL`` pointer)::
>>> print(hex(windll.kernel32.GetModuleHandleA(None))) # doctest: +WINDOWS
0x1d000000
>>> | Windows, you can call the ``GetModuleHandleA()`` function, which returns a win32 module handle (passing ``None`` as single argument to call it with a ``NULL`` pointer)::
>>> print(hex(windll.kernel32.GetModuleHandleA(None))) # doctest: +WINDOWS
0x1d000000
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8eaeaf65-3def-46fc-9459-aa75db522962 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,515 | supabase-export-v2 | 29ee393ef831878f | to return C :c:expr:`int`, which is of course not always the truth, so you have to assign the correct :attr:`!restype` attribute to use these functions.
.. audit-event:: ctypes.dlopen name ctypes.LibraryLoader | trusted_official_docs | CPython Docs | to return C :c:expr:`int`, which is of course not always the truth, so you have to assign the correct :attr:`!restype` attribute to use these functions.
.. audit-event:: ctypes.dlopen name ctypes.LibraryLoader | to return C :c:expr:`int`, which is of course not always the truth, so you have to assign the correct :attr:`!restype` attribute to use these functions.
.. audit-event:: ctypes.dlopen name ctypes.LibraryLoader | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8eb04aa9-5cd3-4d57-a26d-a6a49f24fd51 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,861 | supabase-export-v2 | 9ae60a9f92d0e1cb | The first item is the name of the field, the second item specifies the type of the field; it can be any ctypes data type.
For integer type fields like :class:`c_int`, a third optional item can be
given. It must be a small positive integer defining the bit width of the
field. | trusted_official_docs | CPython Docs | The first item is the name of the field, the second item specifies the type of the field; it can be any ctypes data type.
For integer type fields like :class:`c_int`, a third optional item can be
given. It must be a small positive integer defining the bit width of the
field. | The first item is the name of the field, the second item specifies the type of the field; it can be any ctypes data type.
For integer type fields like :class:`c_int`, a third optional item can be
given. It must be a small positive integer defining the bit width of the
field. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8f562a9b-2796-41bd-a84f-e76a813bd2e7 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,383 | supabase-export-v2 | 21324ba2c11fb043 | ... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in cell NameError: name 'cell' is not defined >>>
because the new ``class cell`` is not available in the class statement itself. In :mod:`!ctypes`, we can define the ``cell`` class and set the
:attr:`~Structure._fields_` ... | trusted_official_docs | CPython Docs | ... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in cell NameError: name 'cell' is not defined >>>
because the new ``class cell`` is not available in the class statement itself. In :mod:`!ctypes`, we can define the ``cell`` class and set the
:attr:`~Structure._fields_` ... | ... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in cell NameError: name 'cell' is not defined >>>
because the new ``class cell`` is not available in the class statement itself. In :mod:`!ctypes`, we can define the ``cell`` class and set the
:attr:`~Structure._fields_` ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8f9b1185-b20b-4554-a573-694131e34bb7 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,548 | supabase-export-v2 | 166254ff05d2fd87 | that relies on code loaded from shared libraries, it can be useful to know which shared libraries have already been loaded into the current process.
The :mod:`!ctypes.util` module provides the :func:`~ctypes.util.dllist` function,
which calls the different APIs provided by the various platforms to help determine
which ... | trusted_official_docs | CPython Docs | that relies on code loaded from shared libraries, it can be useful to know which shared libraries have already been loaded into the current process.
The :mod:`!ctypes.util` module provides the :func:`~ctypes.util.dllist` function,
which calls the different APIs provided by the various platforms to help determine
which ... | that relies on code loaded from shared libraries, it can be useful to know which shared libraries have already been loaded into the current process.
The :mod:`!ctypes.util` module provides the :func:`~ctypes.util.dllist` function,
which calls the different APIs provided by the various platforms to help determine
which ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8ff37f91-503f-47eb-a33f-be3dffe74d5e | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,547 | supabase-export-v2 | 105a46b98959bb65 | Listing loaded shared libraries ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
When writing code that relies on code loaded from shared libraries, it can be
useful to know which shared libraries have already been loaded into the current
process. | trusted_official_docs | CPython Docs | Listing loaded shared libraries ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
When writing code that relies on code loaded from shared libraries, it can be
useful to know which shared libraries have already been loaded into the current
process. | Listing loaded shared libraries ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
When writing code that relies on code loaded from shared libraries, it can be
useful to know which shared libraries have already been loaded into the current
process. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
90bd2602-8bd3-44ed-9e59-4192120181c4 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,432 | supabase-export-v2 | 985408ced5ead701 | >>> temp0, temp1 = rc.b, rc.a >>> rc.a = temp0 >>> rc.b = temp1 >>>
Note that ``temp0`` and ``temp1`` are objects still using the internal buffer of
the ``rc`` object above. So executing ``rc.a = temp0`` copies the buffer
contents of ``temp0`` into ``rc`` 's buffer. This, in turn, changes the
contents of ``temp1``. So,... | trusted_official_docs | CPython Docs | >>> temp0, temp1 = rc.b, rc.a >>> rc.a = temp0 >>> rc.b = temp1 >>>
Note that ``temp0`` and ``temp1`` are objects still using the internal buffer of
the ``rc`` object above. So executing ``rc.a = temp0`` copies the buffer
contents of ``temp0`` into ``rc`` 's buffer. This, in turn, changes the
contents of ``temp1``. So,... | >>> temp0, temp1 = rc.b, rc.a >>> rc.a = temp0 >>> rc.b = temp1 >>>
Note that ``temp0`` and ``temp1`` are objects still using the internal buffer of
the ``rc`` object above. So executing ``rc.a = temp0`` copies the buffer
contents of ``temp0`` into ``rc`` 's buffer. This, in turn, changes the
contents of ``temp1``. So,... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9212bad2-f808-4199-a66b-a09e9f85f55f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,433 | supabase-export-v2 | d30ac3dec71a5503 | ``temp0`` into ``rc`` 's buffer. This, in turn, changes the contents of ``temp1``. So, the last assignment ``rc.b = temp1``, doesn't have the expected effect.
Keep in mind that retrieving sub-objects from Structure, Unions, and Arrays
doesn't *copy* the sub-object, instead it retrieves a wrapper object accessing
the ro... | trusted_official_docs | CPython Docs | ``temp0`` into ``rc`` 's buffer. This, in turn, changes the contents of ``temp1``. So, the last assignment ``rc.b = temp1``, doesn't have the expected effect.
Keep in mind that retrieving sub-objects from Structure, Unions, and Arrays
doesn't *copy* the sub-object, instead it retrieves a wrapper object accessing
the ro... | ``temp0`` into ``rc`` 's buffer. This, in turn, changes the contents of ``temp1``. So, the last assignment ``rc.b = temp1``, doesn't have the expected effect.
Keep in mind that retrieving sub-objects from Structure, Unions, and Arrays
doesn't *copy* the sub-object, instead it retrieves a wrapper object accessing
the ro... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
932158d5-3d7c-44ab-9f33-4ee9668ba561 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,890 | supabase-export-v2 | 98eb240c66e75f5d | :mod:`!ctypes` will create descriptors in the structure type that allows accessing the nested fields directly, without the need to create the structure or union field.
Here is an example type (Windows):: | trusted_official_docs | CPython Docs | :mod:`!ctypes` will create descriptors in the structure type that allows accessing the nested fields directly, without the need to create the structure or union field.
Here is an example type (Windows):: | :mod:`!ctypes` will create descriptors in the structure type that allows accessing the nested fields directly, without the need to create the structure or union field.
Here is an example type (Windows):: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
934d3a16-27de-4f5d-b0e2-6743e144758e | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,339 | supabase-export-v2 | 6f1b9d54f3395fd2 | Assigning another :class:`c_int` instance to the pointer's contents attribute would cause the pointer to point to the memory location where this is stored::
>>> i = c_int(99)
>>> pi.contents = i
>>> pi.contents
c_long(99)
>>> | trusted_official_docs | CPython Docs | Assigning another :class:`c_int` instance to the pointer's contents attribute would cause the pointer to point to the memory location where this is stored::
>>> i = c_int(99)
>>> pi.contents = i
>>> pi.contents
c_long(99)
>>> | Assigning another :class:`c_int` instance to the pointer's contents attribute would cause the pointer to point to the memory location where this is stored::
>>> i = c_int(99)
>>> pi.contents = i
>>> pi.contents
c_long(99)
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
934e677f-36bb-4db8-8e74-3dbd42adfaf7 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,301 | supabase-export-v2 | fca88f3ec04fb16f | >>> print(point.x, point.y) 0 5 >>> POINT(1, 2, 3) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: too many initializers >>>
You can, however, build much more complicated structures. A structure can
itself contain other structures by using a structure as a field type. | trusted_official_docs | CPython Docs | >>> print(point.x, point.y) 0 5 >>> POINT(1, 2, 3) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: too many initializers >>>
You can, however, build much more complicated structures. A structure can
itself contain other structures by using a structure as a field type. | >>> print(point.x, point.y) 0 5 >>> POINT(1, 2, 3) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: too many initializers >>>
You can, however, build much more complicated structures. A structure can
itself contain other structures by using a structure as a field type. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
93c2b74f-0cd7-4e79-896b-54f4dad6270a | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,418 | supabase-export-v2 | 8023e0fffca83a62 | Quoting the docs for that value:
This pointer is initialized to point to an array of :c:struct:`_frozen`
records, terminated by one whose members are all ``NULL`` or zero. When a frozen
module is imported, it is searched in this table. Third-party code could play
tricks with this to provide a dynamically created col... | trusted_official_docs | CPython Docs | Quoting the docs for that value:
This pointer is initialized to point to an array of :c:struct:`_frozen`
records, terminated by one whose members are all ``NULL`` or zero. When a frozen
module is imported, it is searched in this table. Third-party code could play
tricks with this to provide a dynamically created col... | Quoting the docs for that value:
This pointer is initialized to point to an array of :c:struct:`_frozen`
records, terminated by one whose members are all ``NULL`` or zero. When a frozen
module is imported, it is searched in this table. Third-party code could play
tricks with this to provide a dynamically created col... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9460d07f-cd59-498a-b6f4-8e6470e4ff15 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,421 | supabase-export-v2 | adaffd0872b2be56 | >>> >>> class struct_frozen(Structure): ... _fields_ = [("name", c_char_p), ... ("code", POINTER(c_ubyte)), ... ("size", c_int), ... ("get_code", POINTER(c_ubyte)), # Function pointer ... ] ... >>>
We have defined the :c:struct:`_frozen` data type, so we can get the pointer
to the table:: | trusted_official_docs | CPython Docs | >>> >>> class struct_frozen(Structure): ... _fields_ = [("name", c_char_p), ... ("code", POINTER(c_ubyte)), ... ("size", c_int), ... ("get_code", POINTER(c_ubyte)), # Function pointer ... ] ... >>>
We have defined the :c:struct:`_frozen` data type, so we can get the pointer
to the table:: | >>> >>> class struct_frozen(Structure): ... _fields_ = [("name", c_char_p), ... ("code", POINTER(c_ubyte)), ... ("size", c_int), ... ("get_code", POINTER(c_ubyte)), # Function pointer ... ] ... >>>
We have defined the :c:struct:`_frozen` data type, so we can get the pointer
to the table:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
961bd9a5-20a4-462a-87a7-574bbd4f2229 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,181 | supabase-export-v2 | 6a4ef23787c1233e | --------------
:mod:`!ctypes` is a foreign function library for Python. It provides C compatible
data types, and allows calling functions in DLLs or shared libraries. It can be
used to wrap these libraries in pure Python. | trusted_official_docs | CPython Docs | --------------
:mod:`!ctypes` is a foreign function library for Python. It provides C compatible
data types, and allows calling functions in DLLs or shared libraries. It can be
used to wrap these libraries in pure Python. | --------------
:mod:`!ctypes` is a foreign function library for Python. It provides C compatible
data types, and allows calling functions in DLLs or shared libraries. It can be
used to wrap these libraries in pure Python. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
965f5c56-43fc-464b-97d6-079e9e3c2540 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,921 | supabase-export-v2 | b4d915c27e5977d1 | The location of a bitfield within its *storage unit*, that is, within :attr:`~CField.byte_size` bytes of memory starting at :attr:`~CField.byte_offset`.
To get the field's value, read the storage unit as an integer,
:ref:`shift left <shifting>` by :attr:`!bit_offset` and
take the :attr:`!bit_size` least significant b... | trusted_official_docs | CPython Docs | The location of a bitfield within its *storage unit*, that is, within :attr:`~CField.byte_size` bytes of memory starting at :attr:`~CField.byte_offset`.
To get the field's value, read the storage unit as an integer,
:ref:`shift left <shifting>` by :attr:`!bit_offset` and
take the :attr:`!bit_size` least significant b... | The location of a bitfield within its *storage unit*, that is, within :attr:`~CField.byte_size` bytes of memory starting at :attr:`~CField.byte_offset`.
To get the field's value, read the storage unit as an integer,
:ref:`shift left <shifting>` by :attr:`!bit_offset` and
take the :attr:`!bit_size` least significant b... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
96d3a8fb-9078-44c0-9482-76f5dd51317e | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,231 | supabase-export-v2 | 7bc2cd12bc66f6ff | or ``None`` - ``'P'`` * - :class:`py_object` - :c:expr:`PyObject *` - :py:class:`object` - ``'O'`` * - :ref:`VARIANT_BOOL <ctypes-wintypes>` - :c:expr:`short int` - :py:class:`bool` - ``'v'``
Additionally, if IEC 60559 compatible complex arithmetic (Annex G) is supported
in both C and ``libffi``, the following complex ... | trusted_official_docs | CPython Docs | or ``None`` - ``'P'`` * - :class:`py_object` - :c:expr:`PyObject *` - :py:class:`object` - ``'O'`` * - :ref:`VARIANT_BOOL <ctypes-wintypes>` - :c:expr:`short int` - :py:class:`bool` - ``'v'``
Additionally, if IEC 60559 compatible complex arithmetic (Annex G) is supported
in both C and ``libffi``, the following complex ... | or ``None`` - ``'P'`` * - :class:`py_object` - :c:expr:`PyObject *` - :py:class:`object` - ``'O'`` * - :ref:`VARIANT_BOOL <ctypes-wintypes>` - :c:expr:`short int` - :py:class:`bool` - ``'v'``
Additionally, if IEC 60559 compatible complex arithmetic (Annex G) is supported
in both C and ``libffi``, the following complex ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9712b9d2-07ae-46e1-9b3b-2583996d8b70 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,375 | supabase-export-v2 | e662eb602840ad31 | So, :func:`cast` can be used to assign to the ``values`` field of ``Bar`` the structure::
>>> bar = Bar()
>>> bar.values = cast((c_byte * 4)(), POINTER(c_int))
>>> print(bar.values[0])
0
>>> | trusted_official_docs | CPython Docs | So, :func:`cast` can be used to assign to the ``values`` field of ``Bar`` the structure::
>>> bar = Bar()
>>> bar.values = cast((c_byte * 4)(), POINTER(c_int))
>>> print(bar.values[0])
0
>>> | So, :func:`cast` can be used to assign to the ``values`` field of ``Bar`` the structure::
>>> bar = Bar()
>>> bar.values = cast((c_byte * 4)(), POINTER(c_int))
>>> print(bar.values[0])
0
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
972dbc3c-747d-4d7c-b960-82c97206b96b | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,583 | supabase-export-v2 | 3e7c6d0d96bf4991 | .. function:: CFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)
The returned function prototype creates functions that use the standard C
calling convention. The function will release the GIL during the call. If
*use_errno* is set to true, the ctypes private copy of the system
:data:`errno` variab... | trusted_official_docs | CPython Docs | .. function:: CFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)
The returned function prototype creates functions that use the standard C
calling convention. The function will release the GIL during the call. If
*use_errno* is set to true, the ctypes private copy of the system
:data:`errno` variab... | .. function:: CFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)
The returned function prototype creates functions that use the standard C
calling convention. The function will release the GIL during the call. If
*use_errno* is set to true, the ctypes private copy of the system
:data:`errno` variab... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9745c692-2e56-4dc0-93b8-80538c342841 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,762 | supabase-export-v2 | b080aeed1afb05fa | The :mod:`array` and :ref:`struct <format-characters>` modules, as well as third-party modules like `numpy <https://numpy.org/doc/stable/reference/arrays.interface.html#object.__array_interface__>`__, use similar -- but slightly different -- type codes.
Fundamental data types, when returned as foreign function call res... | trusted_official_docs | CPython Docs | The :mod:`array` and :ref:`struct <format-characters>` modules, as well as third-party modules like `numpy <https://numpy.org/doc/stable/reference/arrays.interface.html#object.__array_interface__>`__, use similar -- but slightly different -- type codes.
Fundamental data types, when returned as foreign function call res... | The :mod:`array` and :ref:`struct <format-characters>` modules, as well as third-party modules like `numpy <https://numpy.org/doc/stable/reference/arrays.interface.html#object.__array_interface__>`__, use similar -- but slightly different -- type codes.
Fundamental data types, when returned as foreign function call res... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
97767059-a721-43c6-9c63-76aa0dc4544a | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,363 | supabase-export-v2 | af9df1e40f3a175f | Type conversions ^^^^^^^^^^^^^^^^
Usually, ctypes does strict type checking. This means, if you have
``POINTER(c_int)`` in the :attr:`~_CFuncPtr.argtypes` list of a function or as the type of
a member field in a structure definition, only instances of exactly the same
type are accepted. There are some exceptions to thi... | trusted_official_docs | CPython Docs | Type conversions ^^^^^^^^^^^^^^^^
Usually, ctypes does strict type checking. This means, if you have
``POINTER(c_int)`` in the :attr:`~_CFuncPtr.argtypes` list of a function or as the type of
a member field in a structure definition, only instances of exactly the same
type are accepted. There are some exceptions to thi... | Type conversions ^^^^^^^^^^^^^^^^
Usually, ctypes does strict type checking. This means, if you have
``POINTER(c_int)`` in the :attr:`~_CFuncPtr.argtypes` list of a function or as the type of
a member field in a structure definition, only instances of exactly the same
type are accepted. There are some exceptions to thi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9827543d-1490-4192-9b61-c85fc244a625 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,657 | supabase-export-v2 | 8b4912455f7f239b | This function creates a mutable unicode character buffer. The returned object is a ctypes array of :class:`c_wchar`.
The function takes the same arguments as :func:`~create_string_buffer` except
*init* must be a string and *size* counts :class:`c_wchar`. | trusted_official_docs | CPython Docs | This function creates a mutable unicode character buffer. The returned object is a ctypes array of :class:`c_wchar`.
The function takes the same arguments as :func:`~create_string_buffer` except
*init* must be a string and *size* counts :class:`c_wchar`. | This function creates a mutable unicode character buffer. The returned object is a ctypes array of :class:`c_wchar`.
The function takes the same arguments as :func:`~create_string_buffer` except
*init* must be a string and *size* counts :class:`c_wchar`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
99a35838-861a-4d17-930b-8cf92f095a91 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,895 | supabase-export-v2 | 76fc16368bad03ef | td = TYPEDESC() td.vt = VT_PTR td.lptdesc = POINTER(some_type) td.u.lptdesc = POINTER(some_type)
It is possible to define sub-subclasses of structures, they inherit the
fields of the base class. If the subclass definition has a separate
:attr:`_fields_` variable, the fields specified in this are appended to the
fiel... | trusted_official_docs | CPython Docs | td = TYPEDESC() td.vt = VT_PTR td.lptdesc = POINTER(some_type) td.u.lptdesc = POINTER(some_type)
It is possible to define sub-subclasses of structures, they inherit the
fields of the base class. If the subclass definition has a separate
:attr:`_fields_` variable, the fields specified in this are appended to the
fiel... | td = TYPEDESC() td.vt = VT_PTR td.lptdesc = POINTER(some_type) td.u.lptdesc = POINTER(some_type)
It is possible to define sub-subclasses of structures, they inherit the
fields of the base class. If the subclass definition has a separate
:attr:`_fields_` variable, the fields specified in this are appended to the
fiel... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
99b2b2d0-3dad-404a-9c06-4ecfd00b726f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,260 | supabase-export-v2 | aa1f324421722bb8 | Calling functions with your own custom data types ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can also customize :mod:`!ctypes` argument conversion to allow instances of
your own classes be used as function arguments. :mod:`!ctypes` looks for an
:attr:`!_as_parameter_` attribute and uses this as the function ... | trusted_official_docs | CPython Docs | Calling functions with your own custom data types ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can also customize :mod:`!ctypes` argument conversion to allow instances of
your own classes be used as function arguments. :mod:`!ctypes` looks for an
:attr:`!_as_parameter_` attribute and uses this as the function ... | Calling functions with your own custom data types ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can also customize :mod:`!ctypes` argument conversion to allow instances of
your own classes be used as function arguments. :mod:`!ctypes` looks for an
:attr:`!_as_parameter_` attribute and uses this as the function ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9acf57ab-9bba-4a79-8f69-a74e4d600d5f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,210 | supabase-export-v2 | 219d9dcdbb357fe1 | Windows, some dlls export functions not by name but by ordinal. These functions can be accessed by indexing the dll object with the ordinal number::
>>> cdll.kernel32[1] # doctest: +WINDOWS
<_FuncPtr object at 0x...>
>>> cdll.kernel32[0] # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1,... | trusted_official_docs | CPython Docs | Windows, some dlls export functions not by name but by ordinal. These functions can be accessed by indexing the dll object with the ordinal number::
>>> cdll.kernel32[1] # doctest: +WINDOWS
<_FuncPtr object at 0x...>
>>> cdll.kernel32[0] # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1,... | Windows, some dlls export functions not by name but by ordinal. These functions can be accessed by indexing the dll object with the ordinal number::
>>> cdll.kernel32[1] # doctest: +WINDOWS
<_FuncPtr object at 0x...>
>>> cdll.kernel32[0] # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1,... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9bc213b2-b7a2-410f-a0c9-d0d185ad5473 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,253 | supabase-export-v2 | 45a604f89572e13b | Calling variadic functions ^^^^^^^^^^^^^^^^^^^^^^^^^^
On a lot of platforms calling variadic functions through ctypes is exactly the same
as calling functions with a fixed number of parameters. On some platforms, and in
particular ARM64 for Apple Platforms, the calling convention for variadic functions
is different tha... | trusted_official_docs | CPython Docs | Calling variadic functions ^^^^^^^^^^^^^^^^^^^^^^^^^^
On a lot of platforms calling variadic functions through ctypes is exactly the same
as calling functions with a fixed number of parameters. On some platforms, and in
particular ARM64 for Apple Platforms, the calling convention for variadic functions
is different tha... | Calling variadic functions ^^^^^^^^^^^^^^^^^^^^^^^^^^
On a lot of platforms calling variadic functions through ctypes is exactly the same
as calling functions with a fixed number of parameters. On some platforms, and in
particular ARM64 for Apple Platforms, the calling convention for variadic functions
is different tha... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9c82b105-3fbe-4467-a0de-585f074fdb67 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,644 | supabase-export-v2 | f4ba46a5bd65d049 | the same memory block as *obj*. *type* must be a pointer type, and *obj* must be an object that can be interpreted as a pointer.
.. function:: create_string_buffer(init, size=None)
create_string_buffer(size) | trusted_official_docs | CPython Docs | the same memory block as *obj*. *type* must be a pointer type, and *obj* must be an object that can be interpreted as a pointer.
.. function:: create_string_buffer(init, size=None)
create_string_buffer(size) | the same memory block as *obj*. *type* must be a pointer type, and *obj* must be an object that can be interpreted as a pointer.
.. function:: create_string_buffer(init, size=None)
create_string_buffer(size) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9d309f3a-cbe6-4a03-a1da-a48a1761b59a | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,293 | supabase-export-v2 | fb947e5fea0f35fb | into the corresponding location, or if the data is too large to be passed by value. This is also known as *passing parameters by reference*.
:mod:`!ctypes` exports the :func:`byref` function which is used to pass parameters
by reference. The same effect can be achieved with the :func:`pointer` function,
although :func:... | trusted_official_docs | CPython Docs | into the corresponding location, or if the data is too large to be passed by value. This is also known as *passing parameters by reference*.
:mod:`!ctypes` exports the :func:`byref` function which is used to pass parameters
by reference. The same effect can be achieved with the :func:`pointer` function,
although :func:... | into the corresponding location, or if the data is too large to be passed by value. This is also known as *passing parameters by reference*.
:mod:`!ctypes` exports the :func:`byref` function which is used to pass parameters
by reference. The same effect can be achieved with the :func:`pointer` function,
although :func:... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9d9c91f9-f7cf-4743-a07f-29ac56f8b8cf | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,528 | supabase-export-v2 | 3694dbb43543a9d0 | Try to find a library and return a pathname.
*name* is the "short" library name without any prefix like ``lib``,
suffix like ``.so``, ``.dylib`` or version number. (This is the form used for the posix linker option :option:`!-l`.)
The result is in a format suitable for passing to :py:class:`~ctypes.CDLL`. | trusted_official_docs | CPython Docs | Try to find a library and return a pathname.
*name* is the "short" library name without any prefix like ``lib``,
suffix like ``.so``, ``.dylib`` or version number. (This is the form used for the posix linker option :option:`!-l`.)
The result is in a format suitable for passing to :py:class:`~ctypes.CDLL`. | Try to find a library and return a pathname.
*name* is the "short" library name without any prefix like ``lib``,
suffix like ``.so``, ``.dylib`` or version number. (This is the form used for the posix linker option :option:`!-l`.)
The result is in a format suitable for passing to :py:class:`~ctypes.CDLL`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9dc68fb1-7f31-44e2-9c0d-d1c0b807fced | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,458 | supabase-export-v2 | 24f42072a8bab999 | is the pathname of the shared library to open. If *name* does not contain a path separator, the library is found in a platform-specific way.
On Windows, the ``.DLL`` suffix may be missing. (For details, see
`LoadLibraryExW`_ documentation.)
Other platform-specific prefixes and suffixes (for example, ``lib``,
``.so``... | trusted_official_docs | CPython Docs | is the pathname of the shared library to open. If *name* does not contain a path separator, the library is found in a platform-specific way.
On Windows, the ``.DLL`` suffix may be missing. (For details, see
`LoadLibraryExW`_ documentation.)
Other platform-specific prefixes and suffixes (for example, ``lib``,
``.so``... | is the pathname of the shared library to open. If *name* does not contain a path separator, the library is found in a platform-specific way.
On Windows, the ``.DLL`` suffix may be missing. (For details, see
`LoadLibraryExW`_ documentation.)
Other platform-specific prefixes and suffixes (for example, ``lib``,
``.so``... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9dcf71f8-4a8e-4cc5-95b1-2e4b3f252f4a | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,611 | supabase-export-v2 | 860a2b06ccaec720 | to wrap the Windows ``MessageBoxW`` function so that it supports default parameters and named arguments. The C declaration from the windows header file is this::
WINUSERAPI int WINAPI
MessageBoxW(
HWND hWnd,
LPCWSTR lpText,
LPCWSTR lpCaption,
UINT uType); | trusted_official_docs | CPython Docs | to wrap the Windows ``MessageBoxW`` function so that it supports default parameters and named arguments. The C declaration from the windows header file is this::
WINUSERAPI int WINAPI
MessageBoxW(
HWND hWnd,
LPCWSTR lpText,
LPCWSTR lpCaption,
UINT uType); | to wrap the Windows ``MessageBoxW`` function so that it supports default parameters and named arguments. The C declaration from the windows header file is this::
WINUSERAPI int WINAPI
MessageBoxW(
HWND hWnd,
LPCWSTR lpText,
LPCWSTR lpCaption,
UINT uType); | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9f408851-458b-45de-aafe-df509caed29c | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,379 | supabase-export-v2 | ffd82510bceeb6e6 | *Incomplete Types* are structures, unions or arrays whose members are not yet specified. In C, they are specified by forward declarations, which are defined later::
struct cell; /* forward declaration */ | trusted_official_docs | CPython Docs | *Incomplete Types* are structures, unions or arrays whose members are not yet specified. In C, they are specified by forward declarations, which are defined later::
struct cell; /* forward declaration */ | *Incomplete Types* are structures, unions or arrays whose members are not yet specified. In C, they are specified by forward declarations, which are defined later::
struct cell; /* forward declaration */ | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9fb679dd-c04f-440d-9cb4-a7a977c4ec65 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,395 | supabase-export-v2 | f00ca4a167ee75f9 | >>> IntArray5 = c_int * 5 >>> ia = IntArray5(5, 1, 7, 33, 99) >>> qsort = libc.qsort >>> qsort.restype = None >>>
:func:`!qsort` must be called with a pointer to the data to sort, the number of
items in the data array, the size of one item, and a pointer to the comparison
function, the callback. The callback will then ... | trusted_official_docs | CPython Docs | >>> IntArray5 = c_int * 5 >>> ia = IntArray5(5, 1, 7, 33, 99) >>> qsort = libc.qsort >>> qsort.restype = None >>>
:func:`!qsort` must be called with a pointer to the data to sort, the number of
items in the data array, the size of one item, and a pointer to the comparison
function, the callback. The callback will then ... | >>> IntArray5 = c_int * 5 >>> ia = IntArray5(5, 1, 7, 33, 99) >>> qsort = libc.qsort >>> qsort.restype = None >>>
:func:`!qsort` must be called with a pointer to the data to sort, the number of
items in the data array, the size of one item, and a pointer to the comparison
function, the callback. The callback will then ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a004076e-d2a4-4283-ab6f-6997ca7da3ee | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,589 | supabase-export-v2 | 814135bef18f853f | The returned function prototype creates functions that use the Python calling convention. The function will *not* release the GIL during the call.
Function prototypes created by these factory functions can be instantiated in
different ways, depending on the type and number of the parameters in the call: | trusted_official_docs | CPython Docs | The returned function prototype creates functions that use the Python calling convention. The function will *not* release the GIL during the call.
Function prototypes created by these factory functions can be instantiated in
different ways, depending on the type and number of the parameters in the call: | The returned function prototype creates functions that use the Python calling convention. The function will *not* release the GIL during the call.
Function prototypes created by these factory functions can be instantiated in
different ways, depending on the type and number of the parameters in the call: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a020b098-5359-42a4-907f-106cc4e7d11a | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,540 | supabase-export-v2 | 25e84ba39a5532d9 | system search path, and returns the full pathname, but since there is no predefined naming scheme a call like ``find_library("c")`` will fail and return ``None``.
.. function:: find_msvcrt()
:module: ctypes.util | trusted_official_docs | CPython Docs | system search path, and returns the full pathname, but since there is no predefined naming scheme a call like ``find_library("c")`` will fail and return ``None``.
.. function:: find_msvcrt()
:module: ctypes.util | system search path, and returns the full pathname, but since there is no predefined naming scheme a call like ``find_library("c")`` will fail and return ``None``.
.. function:: find_msvcrt()
:module: ctypes.util | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a1da11d9-e0bc-44fa-a076-e316d5cf5525 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,204 | supabase-export-v2 | 89e7fb46c9584d1c | recent call last): File "<stdin>", line 1, in <module> File "ctypes.py", line 239, in __getattr__ func = _StdcallFuncPtr(name, self) AttributeError: function 'MyOwnFunction' not found >>>
Note that win32 system dlls like ``kernel32`` and ``user32`` often export ANSI
as well as UNICODE versions of a function. The UNICOD... | trusted_official_docs | CPython Docs | recent call last): File "<stdin>", line 1, in <module> File "ctypes.py", line 239, in __getattr__ func = _StdcallFuncPtr(name, self) AttributeError: function 'MyOwnFunction' not found >>>
Note that win32 system dlls like ``kernel32`` and ``user32`` often export ANSI
as well as UNICODE versions of a function. The UNICOD... | recent call last): File "<stdin>", line 1, in <module> File "ctypes.py", line 239, in __getattr__ func = _StdcallFuncPtr(name, self) AttributeError: function 'MyOwnFunction' not found >>>
Note that win32 system dlls like ``kernel32`` and ``user32`` often export ANSI
as well as UNICODE versions of a function. The UNICOD... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a24f96aa-1acc-48a6-beee-4b9b0c191bc4 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,673 | supabase-export-v2 | 4208e56c83426d87 | .. function:: GetLastError()
Returns the last error code set by Windows in the calling thread. This function calls the Windows ``GetLastError()`` function directly,
it does not return the ctypes-private copy of the error code. | trusted_official_docs | CPython Docs | .. function:: GetLastError()
Returns the last error code set by Windows in the calling thread. This function calls the Windows ``GetLastError()`` function directly,
it does not return the ctypes-private copy of the error code. | .. function:: GetLastError()
Returns the last error code set by Windows in the calling thread. This function calls the Windows ``GetLastError()`` function directly,
it does not return the ctypes-private copy of the error code. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a31f5c6e-0422-4f9d-9075-3144fa1aa808 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,862 | supabase-export-v2 | 08dbd9501ddaf1d4 | type fields like :class:`c_int`, a third optional item can be given. It must be a small positive integer defining the bit width of the field.
Field names must be unique within one structure or union. This is not
checked, only one field can be accessed when names are repeated. | trusted_official_docs | CPython Docs | type fields like :class:`c_int`, a third optional item can be given. It must be a small positive integer defining the bit width of the field.
Field names must be unique within one structure or union. This is not
checked, only one field can be accessed when names are repeated. | type fields like :class:`c_int`, a third optional item can be given. It must be a small positive integer defining the bit width of the field.
Field names must be unique within one structure or union. This is not
checked, only one field can be accessed when names are repeated. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a5b3379f-a132-4373-9d00-681c5437ed0a | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,420 | supabase-export-v2 | fbb78a91c08f2db6 | So manipulating this pointer could even prove useful. To restrict the example size, we show only how this table can be read with :mod:`!ctypes`::
>>> from ctypes import *
>>>
>>> class struct_frozen(Structure):
... _fields_ = [("name", c_char_p),
... ("code", POINTER(c_ubyte)),
... ("size", c_int),
... ("get_code... | trusted_official_docs | CPython Docs | So manipulating this pointer could even prove useful. To restrict the example size, we show only how this table can be read with :mod:`!ctypes`::
>>> from ctypes import *
>>>
>>> class struct_frozen(Structure):
... _fields_ = [("name", c_char_p),
... ("code", POINTER(c_ubyte)),
... ("size", c_int),
... ("get_code... | So manipulating this pointer could even prove useful. To restrict the example size, we show only how this table can be read with :mod:`!ctypes`::
>>> from ctypes import *
>>>
>>> class struct_frozen(Structure):
... _fields_ = [("name", c_char_p),
... ("code", POINTER(c_ubyte)),
... ("size", c_int),
... ("get_code... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a80c9c59-bdbe-4c42-9fd2-1e4ca60f5b68 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,885 | supabase-export-v2 | bc1fe924bf701126 | Python releases (for example, when a new platform gains official support, or when a difference between similar platforms is found). Currently the default will be:
- On Windows: ``"ms"``
- When :attr:`~Structure._pack_` is specified: ``"ms"``. (This is deprecated; see :attr:`~Structure._pack_` documentation.)
- Otherw... | trusted_official_docs | CPython Docs | Python releases (for example, when a new platform gains official support, or when a difference between similar platforms is found). Currently the default will be:
- On Windows: ``"ms"``
- When :attr:`~Structure._pack_` is specified: ``"ms"``. (This is deprecated; see :attr:`~Structure._pack_` documentation.)
- Otherw... | Python releases (for example, when a new platform gains official support, or when a difference between similar platforms is found). Currently the default will be:
- On Windows: ``"ms"``
- When :attr:`~Structure._pack_` is specified: ``"ms"``. (This is deprecated; see :attr:`~Structure._pack_` documentation.)
- Otherw... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a82da827-291b-407e-8f95-1308b6bb31cc | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,286 | supabase-export-v2 | 7a5926f065916e65 | Traceback (most recent call last): ctypes.ArgumentError: argument 2: TypeError: one character bytes, bytearray or integer expected >>> print(strchr(b"abcdef", b"x")) None >>> strchr(b"abcdef", b"d") b'def' >>>
You can also use a callable Python object (a function or a class for example) as
the :attr:`~_CFuncPtr.restype... | trusted_official_docs | CPython Docs | Traceback (most recent call last): ctypes.ArgumentError: argument 2: TypeError: one character bytes, bytearray or integer expected >>> print(strchr(b"abcdef", b"x")) None >>> strchr(b"abcdef", b"d") b'def' >>>
You can also use a callable Python object (a function or a class for example) as
the :attr:`~_CFuncPtr.restype... | Traceback (most recent call last): ctypes.ArgumentError: argument 2: TypeError: one character bytes, bytearray or integer expected >>> print(strchr(b"abcdef", b"x")) None >>> strchr(b"abcdef", b"d") b'def' >>>
You can also use a callable Python object (a function or a class for example) as
the :attr:`~_CFuncPtr.restype... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a89c314e-bab6-40d8-8c43-7d8390a752b6 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,598 | supabase-export-v2 | 7b7e05ed25bf66ad | non-negative integer. *name* is name of the COM method. *iid* is an optional pointer to the interface identifier which is used in extended error reporting.
If *iid* is not specified, an :exc:`OSError` is raised if the COM method
call fails. If *iid* is specified, a :exc:`~ctypes.COMError` is raised
instead. | trusted_official_docs | CPython Docs | non-negative integer. *name* is name of the COM method. *iid* is an optional pointer to the interface identifier which is used in extended error reporting.
If *iid* is not specified, an :exc:`OSError` is raised if the COM method
call fails. If *iid* is specified, a :exc:`~ctypes.COMError` is raised
instead. | non-negative integer. *name* is name of the COM method. *iid* is an optional pointer to the interface identifier which is used in extended error reporting.
If *iid* is not specified, an :exc:`OSError` is raised if the COM method
call fails. If *iid* is specified, a :exc:`~ctypes.COMError` is raised
instead. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a9810626-6652-430c-8e6d-c20daecc86b1 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,345 | supabase-export-v2 | 0a6b58c3ff72fb70 | >>> print(i) c_long(99) >>> pi[0] = 22 >>> print(i) c_long(22) >>>
It is also possible to use indexes different from 0, but you must know what
you're doing, just as in C: You can access or change arbitrary memory locations. Generally you only use this feature if you receive a pointer from a C function,
and you *know* t... | trusted_official_docs | CPython Docs | >>> print(i) c_long(99) >>> pi[0] = 22 >>> print(i) c_long(22) >>>
It is also possible to use indexes different from 0, but you must know what
you're doing, just as in C: You can access or change arbitrary memory locations. Generally you only use this feature if you receive a pointer from a C function,
and you *know* t... | >>> print(i) c_long(99) >>> pi[0] = 22 >>> print(i) c_long(22) >>>
It is also possible to use indexes different from 0, but you must know what
you're doing, just as in C: You can access or change arbitrary memory locations. Generally you only use this feature if you receive a pointer from a C function,
and you *know* t... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a992b4c7-332d-48aa-bdb9-d7f80a4890da | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,399 | supabase-export-v2 | c456b63715493c2a | To get started, here is a simple callback that shows the values it gets passed::
>>> def py_cmp_func(a, b):
... print("py_cmp_func", a[0], b[0])
... return 0
... >>> cmp_func = CMPFUNC(py_cmp_func)
>>> | trusted_official_docs | CPython Docs | To get started, here is a simple callback that shows the values it gets passed::
>>> def py_cmp_func(a, b):
... print("py_cmp_func", a[0], b[0])
... return 0
... >>> cmp_func = CMPFUNC(py_cmp_func)
>>> | To get started, here is a simple callback that shows the values it gets passed::
>>> def py_cmp_func(a, b):
... print("py_cmp_func", a[0], b[0])
... return 0
... >>> cmp_func = CMPFUNC(py_cmp_func)
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
aae3bfef-2f0d-4671-953d-fe47913d62d0 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,855 | supabase-export-v2 | 549bdf21de4e0582 | Abstract base class for structures in *little endian* byte order.
Structures and unions with non-native byte order cannot contain pointer type
fields, or any other data types containing pointer type fields. | trusted_official_docs | CPython Docs | Abstract base class for structures in *little endian* byte order.
Structures and unions with non-native byte order cannot contain pointer type
fields, or any other data types containing pointer type fields. | Abstract base class for structures in *little endian* byte order.
Structures and unions with non-native byte order cannot contain pointer type
fields, or any other data types containing pointer type fields. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ab60288c-4608-4687-98db-1fa81a34f1c8 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,653 | supabase-export-v2 | da00d423ccf7838d | For example::
>>> bytes(create_string_buffer(2))
b'\x00\x00'
>>> bytes(create_string_buffer(b'ab'))
b'ab\x00'
>>> bytes(create_string_buffer(b'ab', 2))
b'ab'
>>> bytes(create_string_buffer(b'ab', 4))
b'ab\x00\x00'
>>> bytes(create_string_buffer(b'abcdef', 2))
Traceback (most recent call last):
... ValueError:... | trusted_official_docs | CPython Docs | For example::
>>> bytes(create_string_buffer(2))
b'\x00\x00'
>>> bytes(create_string_buffer(b'ab'))
b'ab\x00'
>>> bytes(create_string_buffer(b'ab', 2))
b'ab'
>>> bytes(create_string_buffer(b'ab', 4))
b'ab\x00\x00'
>>> bytes(create_string_buffer(b'abcdef', 2))
Traceback (most recent call last):
... ValueError:... | For example::
>>> bytes(create_string_buffer(2))
b'\x00\x00'
>>> bytes(create_string_buffer(b'ab'))
b'ab\x00'
>>> bytes(create_string_buffer(b'ab', 2))
b'ab'
>>> bytes(create_string_buffer(b'ab', 4))
b'ab\x00\x00'
>>> bytes(create_string_buffer(b'abcdef', 2))
Traceback (most recent call last):
... ValueError:... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ad5bbfad-ea0f-4c1d-8957-71c06a3e4c86 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,230 | supabase-export-v2 | 5d21be83cc4251e3 | .. list-table:: :header-rows: 1
* - ctypes type
- C type
- Python type
- :py:attr:`~_SimpleCData._type_`
* - :class:`c_bool`
- :c:expr:`_Bool`
- :py:class:`bool`
- ``'?'``
* - :class:`c_char`
- :c:expr:`char`
- 1-character :py:class:`bytes`
- ``'c'``
* - :class:`c_wchar`
- :c:type:`wchar_t`
- 1-character ... | trusted_official_docs | CPython Docs | .. list-table:: :header-rows: 1
* - ctypes type
- C type
- Python type
- :py:attr:`~_SimpleCData._type_`
* - :class:`c_bool`
- :c:expr:`_Bool`
- :py:class:`bool`
- ``'?'``
* - :class:`c_char`
- :c:expr:`char`
- 1-character :py:class:`bytes`
- ``'c'``
* - :class:`c_wchar`
- :c:type:`wchar_t`
- 1-character ... | .. list-table:: :header-rows: 1
* - ctypes type
- C type
- Python type
- :py:attr:`~_SimpleCData._type_`
* - :class:`c_bool`
- :c:expr:`_Bool`
- :py:class:`bool`
- ``'?'``
* - :class:`c_char`
- :c:expr:`char`
- 1-character :py:class:`bytes`
- ``'c'``
* - :class:`c_wchar`
- :c:type:`wchar_t`
- 1-character ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
adb343b6-9853-4562-bd44-90ab6c7d3989 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,633 | supabase-export-v2 | 2e15f59decf3bade | .. function:: byref(obj[, offset])
Returns a light-weight pointer to *obj*, which must be an instance of a
ctypes type. *offset* defaults to zero, and must be an integer that will be
added to the internal pointer value. | trusted_official_docs | CPython Docs | .. function:: byref(obj[, offset])
Returns a light-weight pointer to *obj*, which must be an instance of a
ctypes type. *offset* defaults to zero, and must be an integer that will be
added to the internal pointer value. | .. function:: byref(obj[, offset])
Returns a light-weight pointer to *obj*, which must be an instance of a
ctypes type. *offset* defaults to zero, and must be an integer that will be
added to the internal pointer value. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
afc0aa0f-1650-411d-b929-d6b60bcf9981 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,565 | supabase-export-v2 | ee8b4395ee525398 | .. attribute:: argtypes
Assign a tuple of ctypes types to specify the argument types that the
function accepts. Functions using the ``stdcall`` calling convention can
only be called with the same number of arguments as the length of this
tuple; functions using the C calling convention accept additional,
unspecified... | trusted_official_docs | CPython Docs | .. attribute:: argtypes
Assign a tuple of ctypes types to specify the argument types that the
function accepts. Functions using the ``stdcall`` calling convention can
only be called with the same number of arguments as the length of this
tuple; functions using the C calling convention accept additional,
unspecified... | .. attribute:: argtypes
Assign a tuple of ctypes types to specify the argument types that the
function accepts. Functions using the ``stdcall`` calling convention can
only be called with the same number of arguments as the length of this
tuple; functions using the C calling convention accept additional,
unspecified... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
afdb1c4c-0f15-476f-b538-1e9ef8a7d779 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,530 | supabase-export-v2 | ff44578f65a99670 | If no library can be found, return ``None``.
The exact functionality is system dependent, and is *not guaranteed*
to match the behavior of the compiler, linker, and loader used for
(or by) Python. It is recommended to only use this function as a default or fallback, | trusted_official_docs | CPython Docs | If no library can be found, return ``None``.
The exact functionality is system dependent, and is *not guaranteed*
to match the behavior of the compiler, linker, and loader used for
(or by) Python. It is recommended to only use this function as a default or fallback, | If no library can be found, return ``None``.
The exact functionality is system dependent, and is *not guaranteed*
to match the behavior of the compiler, linker, and loader used for
(or by) Python. It is recommended to only use this function as a default or fallback, | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
afe4b311-4057-4f58-9a53-88fa9a74e082 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,304 | supabase-export-v2 | e72356d6246ab3ee | RECT(Structure): ... _fields_ = [("upperleft", POINT), ... ("lowerright", POINT)] ... >>> rc = RECT(point) >>> print(rc.upperleft.x, rc.upperleft.y) 0 5 >>> print(rc.lowerright.x, rc.lowerright.y) 0 0 >>>
Nested structures can also be initialized in the constructor in several ways:: | trusted_official_docs | CPython Docs | RECT(Structure): ... _fields_ = [("upperleft", POINT), ... ("lowerright", POINT)] ... >>> rc = RECT(point) >>> print(rc.upperleft.x, rc.upperleft.y) 0 5 >>> print(rc.lowerright.x, rc.lowerright.y) 0 0 >>>
Nested structures can also be initialized in the constructor in several ways:: | RECT(Structure): ... _fields_ = [("upperleft", POINT), ... ("lowerright", POINT)] ... >>> rc = RECT(point) >>> print(rc.upperleft.x, rc.upperleft.y) 0 5 >>> print(rc.lowerright.x, rc.lowerright.y) 0 0 >>>
Nested structures can also be initialized in the constructor in several ways:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
aff0da9e-d91e-4526-ba38-75a9ff9e43fc | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,684 | supabase-export-v2 | cd15e3797072de41 | memmove library function: copies *count* bytes from *src* to *dst*. *dst* and *src* must be integers or ctypes instances that can be converted to pointers.
.. function:: memset(dst, c, count) | trusted_official_docs | CPython Docs | memmove library function: copies *count* bytes from *src* to *dst*. *dst* and *src* must be integers or ctypes instances that can be converted to pointers.
.. function:: memset(dst, c, count) | memmove library function: copies *count* bytes from *src* to *dst*. *dst* and *src* must be integers or ctypes instances that can be converted to pointers.
.. function:: memset(dst, c, count) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b01683c0-975d-4f1d-9e5e-dc36777cb42b | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,267 | supabase-export-v2 | 6bb26b796e2eb8a9 | variable number and different types of parameters depending on the format string, on the other hand this is quite handy to experiment with this feature)::
>>> printf.argtypes = [c_char_p, c_char_p, c_int, c_double]
>>> printf(b"String '%s', Int %d, Double %f\n", b"Hi", 10, 2.2)
String 'Hi', Int 10, Double 2.200000
3... | trusted_official_docs | CPython Docs | variable number and different types of parameters depending on the format string, on the other hand this is quite handy to experiment with this feature)::
>>> printf.argtypes = [c_char_p, c_char_p, c_int, c_double]
>>> printf(b"String '%s', Int %d, Double %f\n", b"Hi", 10, 2.2)
String 'Hi', Int 10, Double 2.200000
3... | variable number and different types of parameters depending on the format string, on the other hand this is quite handy to experiment with this feature)::
>>> printf.argtypes = [c_char_p, c_char_p, c_int, c_double]
>>> printf(b"String '%s', Int %d, Double %f\n", b"Hi", 10, 2.2)
String 'Hi', Int 10, Double 2.200000
3... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b152c87a-b5d8-4ae6-89f9-caf35ae32904 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,622 | supabase-export-v2 | 45a7f57c5ffa7157 | returns a ``BOOL`` to signal success or failure, so this function could do the error checking, and raises an exception when the api call failed::
>>> def errcheck(result, func, args):
... if not result:
... raise WinError()
... return args
... >>> GetWindowRect.errcheck = errcheck
>>> | trusted_official_docs | CPython Docs | returns a ``BOOL`` to signal success or failure, so this function could do the error checking, and raises an exception when the api call failed::
>>> def errcheck(result, func, args):
... if not result:
... raise WinError()
... return args
... >>> GetWindowRect.errcheck = errcheck
>>> | returns a ``BOOL`` to signal success or failure, so this function could do the error checking, and raises an exception when the api call failed::
>>> def errcheck(result, func, args):
... if not result:
... raise WinError()
... return args
... >>> GetWindowRect.errcheck = errcheck
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b1bcb7e8-819f-4031-b965-df0a3ea36795 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,370 | supabase-export-v2 | ddb6082e1863e648 | in the same way. The ``Bar`` structure defined above accepts ``POINTER(c_int)`` pointers or :class:`c_int` arrays for its ``values`` field, but not instances of other types::
>>> bar.values = (c_byte * 4)()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: incompatible types, c_byte_A... | trusted_official_docs | CPython Docs | in the same way. The ``Bar`` structure defined above accepts ``POINTER(c_int)`` pointers or :class:`c_int` arrays for its ``values`` field, but not instances of other types::
>>> bar.values = (c_byte * 4)()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: incompatible types, c_byte_A... | in the same way. The ``Bar`` structure defined above accepts ``POINTER(c_int)`` pointers or :class:`c_int` arrays for its ``values`` field, but not instances of other types::
>>> bar.values = (c_byte * 4)()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: incompatible types, c_byte_A... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b27970ff-d0a5-414a-aabf-107e7f9e5dd7 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,366 | supabase-export-v2 | 15ed0ae3eb3076b2 | of the pointed type (``c_int`` in this case) can be passed to the function. ctypes will apply the required :func:`byref` conversion in this case automatically.
To set a POINTER type field to ``NULL``, you can assign ``None``:: | trusted_official_docs | CPython Docs | of the pointed type (``c_int`` in this case) can be passed to the function. ctypes will apply the required :func:`byref` conversion in this case automatically.
To set a POINTER type field to ``NULL``, you can assign ``None``:: | of the pointed type (``c_int`` in this case) can be passed to the function. ctypes will apply the required :func:`byref` conversion in this case automatically.
To set a POINTER type field to ``NULL``, you can assign ``None``:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b2e99159-3ae1-499b-aa00-fcb256cbd741 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,261 | supabase-export-v2 | eb49de6f928dce9e | and uses this as the function argument. The attribute must be an integer, string, bytes, a :mod:`!ctypes` instance, or an object with an :attr:`!_as_parameter_` attribute::
>>> class Bottles:
... def __init__(self, number):
... self._as_parameter_ = number
... >>> bottles = Bottles(42)
>>> printf(b"%d bottles of be... | trusted_official_docs | CPython Docs | and uses this as the function argument. The attribute must be an integer, string, bytes, a :mod:`!ctypes` instance, or an object with an :attr:`!_as_parameter_` attribute::
>>> class Bottles:
... def __init__(self, number):
... self._as_parameter_ = number
... >>> bottles = Bottles(42)
>>> printf(b"%d bottles of be... | and uses this as the function argument. The attribute must be an integer, string, bytes, a :mod:`!ctypes` instance, or an object with an :attr:`!_as_parameter_` attribute::
>>> class Bottles:
... def __init__(self, number):
... self._as_parameter_ = number
... >>> bottles = Bottles(42)
>>> printf(b"%d bottles of be... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b2ea3eb0-e8c6-4a48-a9f1-3efe76423bfc | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,424 | supabase-export-v2 | f65c2458e17d4b2d | it would probably crash with an access violation or whatever, so it's better to break out of the loop when we hit the ``NULL`` entry::
>>> for item in table:
... if item.name is None:
... break
... print(item.name.decode("ascii"), item.size)
... _frozen_importlib 31764
_frozen_importlib_external 41499
zipimport 1... | trusted_official_docs | CPython Docs | it would probably crash with an access violation or whatever, so it's better to break out of the loop when we hit the ``NULL`` entry::
>>> for item in table:
... if item.name is None:
... break
... print(item.name.decode("ascii"), item.size)
... _frozen_importlib 31764
_frozen_importlib_external 41499
zipimport 1... | it would probably crash with an access violation or whatever, so it's better to break out of the loop when we hit the ``NULL`` entry::
>>> for item in table:
... if item.name is None:
... break
... print(item.name.decode("ascii"), item.size)
... _frozen_importlib 31764
_frozen_importlib_external 41499
zipimport 1... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b2f8f57a-784a-423e-b644-e6890d1a50eb | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,867 | supabase-export-v2 | 259dc929691b84fa | an :exc:`AttributeError`. If :attr:`!_fields_` has not been set before such use, the structure or union will have no own fields, as if :attr:`!_fields_` was empty.
Sub-subclasses of structure types inherit the fields of the base class
plus the :attr:`_fields_` defined in the sub-subclass, if any. | trusted_official_docs | CPython Docs | an :exc:`AttributeError`. If :attr:`!_fields_` has not been set before such use, the structure or union will have no own fields, as if :attr:`!_fields_` was empty.
Sub-subclasses of structure types inherit the fields of the base class
plus the :attr:`_fields_` defined in the sub-subclass, if any. | an :exc:`AttributeError`. If :attr:`!_fields_` has not been set before such use, the structure or union will have no own fields, as if :attr:`!_fields_` was empty.
Sub-subclasses of structure types inherit the fields of the base class
plus the :attr:`_fields_` defined in the sub-subclass, if any. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b3dae099-8a41-432e-863c-268e1c8dec5c | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,386 | supabase-export-v2 | 8fd461c9e57529a5 | Let's try it. We create two instances of ``cell``, and let them point to each other, and finally follow the pointer chain a few times::
>>> c1 = cell()
>>> c1.name = b"foo"
>>> c2 = cell()
>>> c2.name = b"bar"
>>> c1.next = pointer(c2)
>>> c2.next = pointer(c1)
>>> p = c1
>>> for i in range(8):
... print(p.name... | trusted_official_docs | CPython Docs | Let's try it. We create two instances of ``cell``, and let them point to each other, and finally follow the pointer chain a few times::
>>> c1 = cell()
>>> c1.name = b"foo"
>>> c2 = cell()
>>> c2.name = b"bar"
>>> c1.next = pointer(c2)
>>> c2.next = pointer(c1)
>>> p = c1
>>> for i in range(8):
... print(p.name... | Let's try it. We create two instances of ``cell``, and let them point to each other, and finally follow the pointer chain a few times::
>>> c1 = cell()
>>> c1.name = b"foo"
>>> c2 = cell()
>>> c2.name = b"bar"
>>> c1.next = pointer(c2)
>>> c2.next = pointer(c1)
>>> p = c1
>>> for i in range(8):
... print(p.name... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b47a5924-947c-4583-b530-779542062791 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,402 | supabase-export-v2 | 1b4a83f0e123d28b | >>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +LINUX py_cmp_func 5 1 py_cmp_func 33 99 py_cmp_func 7 33 py_cmp_func 5 7 py_cmp_func 1 7 >>>
Now we can actually compare the two items and return a useful result:: | trusted_official_docs | CPython Docs | >>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +LINUX py_cmp_func 5 1 py_cmp_func 33 99 py_cmp_func 7 33 py_cmp_func 5 7 py_cmp_func 1 7 >>>
Now we can actually compare the two items and return a useful result:: | >>> qsort(ia, len(ia), sizeof(c_int), cmp_func) # doctest: +LINUX py_cmp_func 5 1 py_cmp_func 33 99 py_cmp_func 7 33 py_cmp_func 5 7 py_cmp_func 1 7 >>>
Now we can actually compare the two items and return a useful result:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b62bab0f-b344-4400-a7c9-a49000399cc9 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,462 | supabase-export-v2 | 8535e22a9ad7df3c | Since CPython is linked to ``libc``, a ``None`` *name* is often used to access the C standard library::
>>> printf = ctypes.CDLL(None).printf
>>> printf.argtypes = [ctypes.c_char_p]
>>> printf(b"hello\n")
hello
6 | trusted_official_docs | CPython Docs | Since CPython is linked to ``libc``, a ``None`` *name* is often used to access the C standard library::
>>> printf = ctypes.CDLL(None).printf
>>> printf.argtypes = [ctypes.c_char_p]
>>> printf(b"hello\n")
hello
6 | Since CPython is linked to ``libc``, a ``None`` *name* is often used to access the C standard library::
>>> printf = ctypes.CDLL(None).printf
>>> printf.argtypes = [ctypes.c_char_p]
>>> printf(b"hello\n")
hello
6 | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b72595c9-b169-490a-9cd6-df892a076823 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,597 | supabase-export-v2 | 5e87b678ebe13828 | .. function:: prototype(vtbl_index, name[, paramflags[, iid]]) :noindex: :module:
Returns a foreign function that will call a COM method. *vtbl_index* is
the index into the virtual function table, a small non-negative
integer. *name* is name of the COM method. *iid* is an optional pointer to
the interface identifier... | trusted_official_docs | CPython Docs | .. function:: prototype(vtbl_index, name[, paramflags[, iid]]) :noindex: :module:
Returns a foreign function that will call a COM method. *vtbl_index* is
the index into the virtual function table, a small non-negative
integer. *name* is name of the COM method. *iid* is an optional pointer to
the interface identifier... | .. function:: prototype(vtbl_index, name[, paramflags[, iid]]) :noindex: :module:
Returns a foreign function that will call a COM method. *vtbl_index* is
the index into the virtual function table, a small non-negative
integer. *name* is name of the COM method. *iid* is an optional pointer to
the interface identifier... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b7566e1a-2d94-4b7f-a042-880d810e991c | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,566 | supabase-export-v2 | a9f67773a23c0a38 | called with the same number of arguments as the length of this tuple; functions using the C calling convention accept additional, unspecified arguments as well.
When a foreign function is called, each actual argument is passed to the
:meth:`~_CData.from_param` class method of the items in the :attr:`argtypes`
tuple, ... | trusted_official_docs | CPython Docs | called with the same number of arguments as the length of this tuple; functions using the C calling convention accept additional, unspecified arguments as well.
When a foreign function is called, each actual argument is passed to the
:meth:`~_CData.from_param` class method of the items in the :attr:`argtypes`
tuple, ... | called with the same number of arguments as the length of this tuple; functions using the C calling convention accept additional, unspecified arguments as well.
When a foreign function is called, each actual argument is passed to the
:meth:`~_CData.from_param` class method of the items in the :attr:`argtypes`
tuple, ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b785a512-e87d-4036-a026-71a1783d2c85 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,575 | supabase-export-v2 | c0450a5160e38a63 | be returned from the foreign function call, but it can also check the result value and raise an exception if the foreign function call failed.
.. audit-event:: ctypes.set_exception code foreign-functions | trusted_official_docs | CPython Docs | be returned from the foreign function call, but it can also check the result value and raise an exception if the foreign function call failed.
.. audit-event:: ctypes.set_exception code foreign-functions | be returned from the foreign function call, but it can also check the result value and raise an exception if the foreign function call failed.
.. audit-event:: ctypes.set_exception code foreign-functions | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ba41a556-8c89-495c-a6b6-095aec4561f8 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,708 | supabase-export-v2 | 87a869795513952f | .. function:: WinError(code=None, descr=None)
Creates an instance of :exc:`OSError`. If *code* is not specified,
:func:`GetLastError` is called to determine the error code. If *descr* is not
specified, :func:`FormatError` is called to get a textual description of the
error. | trusted_official_docs | CPython Docs | .. function:: WinError(code=None, descr=None)
Creates an instance of :exc:`OSError`. If *code* is not specified,
:func:`GetLastError` is called to determine the error code. If *descr* is not
specified, :func:`FormatError` is called to get a textual description of the
error. | .. function:: WinError(code=None, descr=None)
Creates an instance of :exc:`OSError`. If *code* is not specified,
:func:`GetLastError` is called to determine the error code. If *descr* is not
specified, :func:`FormatError` is called to get a textual description of the
error. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ba4d3c7b-7476-4a91-83e7-02f9f49b61b9 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,647 | supabase-export-v2 | a7f7533e16c62e4b | If *size* is given (and not ``None``), it must be an :class:`int`. It specifies the size of the returned array.
If the *init* argument is given, it must be :class:`bytes`. It is used
to initialize the array items. Bytes not initialized this way are
set to zero (NUL). | trusted_official_docs | CPython Docs | If *size* is given (and not ``None``), it must be an :class:`int`. It specifies the size of the returned array.
If the *init* argument is given, it must be :class:`bytes`. It is used
to initialize the array items. Bytes not initialized this way are
set to zero (NUL). | If *size* is given (and not ``None``), it must be an :class:`int`. It specifies the size of the returned array.
If the *init* argument is given, it must be :class:`bytes`. It is used
to initialize the array items. Bytes not initialized this way are
set to zero (NUL). | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bbb7ed89-158a-46bd-b01e-77f02adac3aa | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,403 | supabase-export-v2 | 9d07a4a7f46299eb | Now we can actually compare the two items and return a useful result::
>>> def py_cmp_func(a, b):
... print("py_cmp_func", a[0], b[0])
... return a[0] - b[0]
... >>>
>>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func)) # doctest: +LINUX
py_cmp_func 5 1
py_cmp_func 33 99
py_cmp_func 7 33
py_cmp_func 1 7
... | trusted_official_docs | CPython Docs | Now we can actually compare the two items and return a useful result::
>>> def py_cmp_func(a, b):
... print("py_cmp_func", a[0], b[0])
... return a[0] - b[0]
... >>>
>>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func)) # doctest: +LINUX
py_cmp_func 5 1
py_cmp_func 33 99
py_cmp_func 7 33
py_cmp_func 1 7
... | Now we can actually compare the two items and return a useful result::
>>> def py_cmp_func(a, b):
... print("py_cmp_func", a[0], b[0])
... return a[0] - b[0]
... >>>
>>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func)) # doctest: +LINUX
py_cmp_func 5 1
py_cmp_func 33 99
py_cmp_func 7 33
py_cmp_func 1 7
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bbb8d2f7-0606-469f-9344-862a1680a015 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,603 | supabase-export-v2 | 9cca2776141eb2e6 | *paramflags* must be a tuple of the same length as :attr:`~_CFuncPtr.argtypes`.
Each item in this tuple contains further information about a parameter, it must
be a tuple containing one, two, or three items. | trusted_official_docs | CPython Docs | *paramflags* must be a tuple of the same length as :attr:`~_CFuncPtr.argtypes`.
Each item in this tuple contains further information about a parameter, it must
be a tuple containing one, two, or three items. | *paramflags* must be a tuple of the same length as :attr:`~_CFuncPtr.argtypes`.
Each item in this tuple contains further information about a parameter, it must
be a tuple containing one, two, or three items. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bc8b68e0-62dd-4c37-9c52-dedfca96e72c | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,390 | supabase-export-v2 | 57fb2827b3ecf594 | :mod:`!ctypes` allows creating C callable function pointers from Python callables. These are sometimes called *callback functions*.
First, you must create a class for the callback function. The class knows the
calling convention, the return type, and the number and types of arguments this
function will receive. | trusted_official_docs | CPython Docs | :mod:`!ctypes` allows creating C callable function pointers from Python callables. These are sometimes called *callback functions*.
First, you must create a class for the callback function. The class knows the
calling convention, the return type, and the number and types of arguments this
function will receive. | :mod:`!ctypes` allows creating C callable function pointers from Python callables. These are sometimes called *callback functions*.
First, you must create a class for the callback function. The class knows the
calling convention, the return type, and the number and types of arguments this
function will receive. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bce16648-06b5-45e9-82ae-954207fba9d9 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,623 | supabase-export-v2 | b5a49e77742941f7 | >>> def errcheck(result, func, args): ... if not result: ... raise WinError() ... return args ... >>> GetWindowRect.errcheck = errcheck >>>
If the :attr:`~_CFuncPtr.errcheck` function returns the argument tuple it receives
unchanged, :mod:`!ctypes` continues the normal processing it does on the output
parameters. If yo... | trusted_official_docs | CPython Docs | >>> def errcheck(result, func, args): ... if not result: ... raise WinError() ... return args ... >>> GetWindowRect.errcheck = errcheck >>>
If the :attr:`~_CFuncPtr.errcheck` function returns the argument tuple it receives
unchanged, :mod:`!ctypes` continues the normal processing it does on the output
parameters. If yo... | >>> def errcheck(result, func, args): ... if not result: ... raise WinError() ... return args ... >>> GetWindowRect.errcheck = errcheck >>>
If the :attr:`~_CFuncPtr.errcheck` function returns the argument tuple it receives
unchanged, :mod:`!ctypes` continues the normal processing it does on the output
parameters. If yo... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bd99fe7e-2b78-413f-adfc-480c87178443 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,581 | supabase-export-v2 | ac4029c925d51eec | Function prototypes ^^^^^^^^^^^^^^^^^^^
Foreign functions can also be created by instantiating function prototypes. Function prototypes are similar to function prototypes in C; they describe a
function (return type, argument types, calling convention) without defining an
implementation. The factory functions must be ca... | trusted_official_docs | CPython Docs | Function prototypes ^^^^^^^^^^^^^^^^^^^
Foreign functions can also be created by instantiating function prototypes. Function prototypes are similar to function prototypes in C; they describe a
function (return type, argument types, calling convention) without defining an
implementation. The factory functions must be ca... | Function prototypes ^^^^^^^^^^^^^^^^^^^
Foreign functions can also be created by instantiating function prototypes. Function prototypes are similar to function prototypes in C; they describe a
function (return type, argument types, calling convention) without defining an
implementation. The factory functions must be ca... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
be47d67f-9a09-4cc6-8939-32b7045c51a9 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,884 | supabase-export-v2 | 9a50c9582aa00946 | by GCC with the System V or “SysV-like” data model, as used on Linux and macOS. With this layout, :attr:`~Structure._pack_` must be unset or zero.
If not set explicitly, ``ctypes`` will use a default that
matches the platform conventions. This default may change in future
Python releases (for example, when a new plat... | trusted_official_docs | CPython Docs | by GCC with the System V or “SysV-like” data model, as used on Linux and macOS. With this layout, :attr:`~Structure._pack_` must be unset or zero.
If not set explicitly, ``ctypes`` will use a default that
matches the platform conventions. This default may change in future
Python releases (for example, when a new plat... | by GCC with the System V or “SysV-like” data model, as used on Linux and macOS. With this layout, :attr:`~Structure._pack_` must be unset or zero.
If not set explicitly, ``ctypes`` will use a default that
matches the platform conventions. This default may change in future
Python releases (for example, when a new plat... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c0008754-cf02-49f3-a6df-7dd4e46c9e1f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,692 | supabase-export-v2 | aa70b62173d2d71b | Create a new pointer instance, pointing to *obj*. The returned object is of the type ``POINTER(type(obj))``.
Note: If you just want to pass a pointer to an object to a foreign function
call, you should use ``byref(obj)`` which is much faster. | trusted_official_docs | CPython Docs | Create a new pointer instance, pointing to *obj*. The returned object is of the type ``POINTER(type(obj))``.
Note: If you just want to pass a pointer to an object to a foreign function
call, you should use ``byref(obj)`` which is much faster. | Create a new pointer instance, pointing to *obj*. The returned object is of the type ``POINTER(type(obj))``.
Note: If you just want to pass a pointer to an object to a foreign function
call, you should use ``byref(obj)`` which is much faster. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c0511e98-49f2-4361-b49f-910bca9403ff | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,307 | supabase-export-v2 | ffd94fbbfb44eb3d | Field :term:`descriptor`\s can be retrieved from the *class*, they are useful for debugging because they can provide useful information. See :class:`CField`::
>>> POINT.x
<ctypes.CField 'x' type=c_int, ofs=0, size=4>
>>> POINT.y
<ctypes.CField 'y' type=c_int, ofs=4, size=4>
>>> | trusted_official_docs | CPython Docs | Field :term:`descriptor`\s can be retrieved from the *class*, they are useful for debugging because they can provide useful information. See :class:`CField`::
>>> POINT.x
<ctypes.CField 'x' type=c_int, ofs=0, size=4>
>>> POINT.y
<ctypes.CField 'y' type=c_int, ofs=4, size=4>
>>> | Field :term:`descriptor`\s can be retrieved from the *class*, they are useful for debugging because they can provide useful information. See :class:`CField`::
>>> POINT.x
<ctypes.CField 'x' type=c_int, ofs=0, size=4>
>>> POINT.y
<ctypes.CField 'y' type=c_int, ofs=4, size=4>
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c15e6dfb-4851-458d-b3be-6be9584ba3f7 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,689 | supabase-export-v2 | b3e137c56d103ba5 | .. impl-detail::
The resulting pointer type is cached in the ``__pointer_type__``
attribute of *type*. It is possible to set this attribute before the first call to
``POINTER`` in order to set a custom pointer type. However, doing this is discouraged: manually creating a suitable
pointer type is difficult without re... | trusted_official_docs | CPython Docs | .. impl-detail::
The resulting pointer type is cached in the ``__pointer_type__``
attribute of *type*. It is possible to set this attribute before the first call to
``POINTER`` in order to set a custom pointer type. However, doing this is discouraged: manually creating a suitable
pointer type is difficult without re... | .. impl-detail::
The resulting pointer type is cached in the ``__pointer_type__``
attribute of *type*. It is possible to set this attribute before the first call to
``POINTER`` in order to set a custom pointer type. However, doing this is discouraged: manually creating a suitable
pointer type is difficult without re... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c1fa1b45-ca20-40c0-ba25-b7b46f30d7ab | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,879 | supabase-export-v2 | e01c2713ebd88191 | :attr:`!_align_` can only *increase* a structure's alignment requirements. Setting it to 0 or 1 has no effect.
Using values that are not powers of two is discouraged and may lead to
surprising behavior. | trusted_official_docs | CPython Docs | :attr:`!_align_` can only *increase* a structure's alignment requirements. Setting it to 0 or 1 has no effect.
Using values that are not powers of two is discouraged and may lead to
surprising behavior. | :attr:`!_align_` can only *increase* a structure's alignment requirements. Setting it to 0 or 1 has no effect.
Using values that are not powers of two is discouraged and may lead to
surprising behavior. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c3543fcd-37c7-4d2a-bb34-73ebf959698f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,355 | supabase-export-v2 | 49e80e50e1be1678 | Thread safety without the GIL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
From Python 3.13 onward, the :term:`GIL` can be disabled on the :term:`free-threaded build`. In ctypes, reads and writes to a single object concurrently is safe, but not across multiple objects: | trusted_official_docs | CPython Docs | Thread safety without the GIL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
From Python 3.13 onward, the :term:`GIL` can be disabled on the :term:`free-threaded build`. In ctypes, reads and writes to a single object concurrently is safe, but not across multiple objects: | Thread safety without the GIL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
From Python 3.13 onward, the :term:`GIL` can be disabled on the :term:`free-threaded build`. In ctypes, reads and writes to a single object concurrently is safe, but not across multiple objects: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c4133b1e-76be-49cd-9111-eff6a665abe9 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,563 | supabase-export-v2 | e1fdf76fee220faf | Assign a ctypes type to specify the result type of the foreign function. Use ``None`` for :c:expr:`void`, a function not returning anything.
It is possible to assign a callable Python object that is not a ctypes
type, in this case the function is assumed to return a C :c:expr:`int`, and
the callable will be called wi... | trusted_official_docs | CPython Docs | Assign a ctypes type to specify the result type of the foreign function. Use ``None`` for :c:expr:`void`, a function not returning anything.
It is possible to assign a callable Python object that is not a ctypes
type, in this case the function is assumed to return a C :c:expr:`int`, and
the callable will be called wi... | Assign a ctypes type to specify the result type of the foreign function. Use ``None`` for :c:expr:`void`, a function not returning anything.
It is possible to assign a callable Python object that is not a ctypes
type, in this case the function is assumed to return a C :c:expr:`int`, and
the callable will be called wi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c528abce-ee7d-4b2e-8a7b-12b9d38f6f7f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,384 | supabase-export-v2 | e5e585ceb194a1ad | not available in the class statement itself. In :mod:`!ctypes`, we can define the ``cell`` class and set the :attr:`~Structure._fields_` attribute later, after the class statement::
>>> from ctypes import *
>>> class cell(Structure):
... pass
... >>> cell._fields_ = [("name", c_char_p),
... ("next", POINTER(cell))]... | trusted_official_docs | CPython Docs | not available in the class statement itself. In :mod:`!ctypes`, we can define the ``cell`` class and set the :attr:`~Structure._fields_` attribute later, after the class statement::
>>> from ctypes import *
>>> class cell(Structure):
... pass
... >>> cell._fields_ = [("name", c_char_p),
... ("next", POINTER(cell))]... | not available in the class statement itself. In :mod:`!ctypes`, we can define the ``cell`` class and set the :attr:`~Structure._fields_` attribute later, after the class statement::
>>> from ctypes import *
>>> class cell(Structure):
... pass
... >>> cell._fields_ = [("name", c_char_p),
... ("next", POINTER(cell))]... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c58e8875-0cee-459b-bd9f-7f1fd957c9d3 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,621 | supabase-export-v2 | ef3bb3a9108bca22 | or a tuple containing the output parameter values when there are more than one, so the GetWindowRect function now returns a RECT instance, when called.
Output parameters can be combined with the :attr:`~_CFuncPtr.errcheck` protocol to do
further output processing and error checking. The win32 ``GetWindowRect`` api
func... | trusted_official_docs | CPython Docs | or a tuple containing the output parameter values when there are more than one, so the GetWindowRect function now returns a RECT instance, when called.
Output parameters can be combined with the :attr:`~_CFuncPtr.errcheck` protocol to do
further output processing and error checking. The win32 ``GetWindowRect`` api
func... | or a tuple containing the output parameter values when there are more than one, so the GetWindowRect function now returns a RECT instance, when called.
Output parameters can be combined with the :attr:`~_CFuncPtr.errcheck` protocol to do
further output processing and error checking. The win32 ``GetWindowRect`` api
func... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c5e5b45e-69a3-4ede-ba6a-66c4dbc82fd8 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,189 | supabase-export-v2 | 5a79f4908faeeea6 | :mod:`!ctypes` exports the :py:data:`~ctypes.cdll`, and on Windows :py:data:`~ctypes.windll` and :py:data:`~ctypes.oledll` objects, for loading dynamic link libraries.
You load libraries by accessing them as attributes of these objects. :py:data:`!cdll` loads libraries which export functions using the
standard ``cdecl`... | trusted_official_docs | CPython Docs | :mod:`!ctypes` exports the :py:data:`~ctypes.cdll`, and on Windows :py:data:`~ctypes.windll` and :py:data:`~ctypes.oledll` objects, for loading dynamic link libraries.
You load libraries by accessing them as attributes of these objects. :py:data:`!cdll` loads libraries which export functions using the
standard ``cdecl`... | :mod:`!ctypes` exports the :py:data:`~ctypes.cdll`, and on Windows :py:data:`~ctypes.windll` and :py:data:`~ctypes.oledll` objects, for loading dynamic link libraries.
You load libraries by accessing them as attributes of these objects. :py:data:`!cdll` loads libraries which export functions using the
standard ``cdecl`... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c67cd7ec-921c-4d2f-8573-31977bafacea | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,415 | supabase-export-v2 | 501bafa0e835dc5a | can access values like this with the :meth:`~_CData.in_dll` class methods of the type. *pythonapi* is a predefined symbol giving access to the Python C api::
>>> version = ctypes.c_int.in_dll(ctypes.pythonapi, "Py_Version")
>>> print(hex(version.value))
0x30c00a0 | trusted_official_docs | CPython Docs | can access values like this with the :meth:`~_CData.in_dll` class methods of the type. *pythonapi* is a predefined symbol giving access to the Python C api::
>>> version = ctypes.c_int.in_dll(ctypes.pythonapi, "Py_Version")
>>> print(hex(version.value))
0x30c00a0 | can access values like this with the :meth:`~_CData.in_dll` class methods of the type. *pythonapi* is a predefined symbol giving access to the Python C api::
>>> version = ctypes.c_int.in_dll(ctypes.pythonapi, "Py_Version")
>>> print(hex(version.value))
0x30c00a0 | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
caa4bbb4-4505-42a0-8e7a-5e7db25c1bf6 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,743 | supabase-export-v2 | ad3f49564b4da945 | .. attribute:: _b_base_
Sometimes ctypes data instances do not own the memory block they contain,
instead they share part of the memory block of a base object. The
:attr:`_b_base_` read-only member is the root ctypes object that owns the
memory block. | trusted_official_docs | CPython Docs | .. attribute:: _b_base_
Sometimes ctypes data instances do not own the memory block they contain,
instead they share part of the memory block of a base object. The
:attr:`_b_base_` read-only member is the root ctypes object that owns the
memory block. | .. attribute:: _b_base_
Sometimes ctypes data instances do not own the memory block they contain,
instead they share part of the memory block of a base object. The
:attr:`_b_base_` read-only member is the root ctypes object that owns the
memory block. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
caacf559-63a2-4707-905a-9b5dca3b8a69 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,896 | supabase-export-v2 | 8b6539af4d384fb4 | base class. If the subclass definition has a separate :attr:`_fields_` variable, the fields specified in this are appended to the fields of the base class.
Structure and union constructors accept both positional and keyword
arguments. Positional arguments are used to initialize member fields in the
same order as they... | trusted_official_docs | CPython Docs | base class. If the subclass definition has a separate :attr:`_fields_` variable, the fields specified in this are appended to the fields of the base class.
Structure and union constructors accept both positional and keyword
arguments. Positional arguments are used to initialize member fields in the
same order as they... | base class. If the subclass definition has a separate :attr:`_fields_` variable, the fields specified in this are appended to the fields of the base class.
Structure and union constructors accept both positional and keyword
arguments. Positional arguments are used to initialize member fields in the
same order as they... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cabac179-c0a2-4884-97ca-c40e2c8479f4 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,223 | supabase-export-v2 | 61db746265f623dc | >>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: exception: access violation reading 0x00000020 >>>
There are, however, enough ways to crash Python with :mod:`!ctypes`, so you
should be careful anyway. The :mod:`faulthandler` mo... | trusted_official_docs | CPython Docs | >>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: exception: access violation reading 0x00000020 >>>
There are, however, enough ways to crash Python with :mod:`!ctypes`, so you
should be careful anyway. The :mod:`faulthandler` mo... | >>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: exception: access violation reading 0x00000020 >>>
There are, however, enough ways to crash Python with :mod:`!ctypes`, so you
should be careful anyway. The :mod:`faulthandler` mo... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cad373de-b146-4dd1-bdd9-9c261c388be9 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,516 | supabase-export-v2 | ceeea0339e18d34a | .. audit-event:: ctypes.dlopen name ctypes.LibraryLoader
Loading a library through any of these objects raises an
:ref:`auditing event <auditing>` ``ctypes.dlopen`` with string argument
``name``, the name used to load the library. | trusted_official_docs | CPython Docs | .. audit-event:: ctypes.dlopen name ctypes.LibraryLoader
Loading a library through any of these objects raises an
:ref:`auditing event <auditing>` ``ctypes.dlopen`` with string argument
``name``, the name used to load the library. | .. audit-event:: ctypes.dlopen name ctypes.LibraryLoader
Loading a library through any of these objects raises an
:ref:`auditing event <auditing>` ``ctypes.dlopen`` with string argument
``name``, the name used to load the library. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cb90c832-02e6-4fda-80df-aa3eb12d87a0 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,609 | supabase-export-v2 | 8df8563bb3015b39 | The optional second item is the parameter name as string. If this is specified, the foreign function can be called with named parameters.
The optional third item is the default value for this parameter. | trusted_official_docs | CPython Docs | The optional second item is the parameter name as string. If this is specified, the foreign function can be called with named parameters.
The optional third item is the default value for this parameter. | The optional second item is the parameter name as string. If this is specified, the foreign function can be called with named parameters.
The optional third item is the default value for this parameter. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cc55279b-44f8-45f0-ac93-ea9bc679e563 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,736 | supabase-export-v2 | 326a2e26966d5864 | .. method:: in_dll(library, name)
This method returns a ctypes type instance exported by a shared
library. *name* is the name of the symbol that exports the data, *library*
is the loaded shared library. | trusted_official_docs | CPython Docs | .. method:: in_dll(library, name)
This method returns a ctypes type instance exported by a shared
library. *name* is the name of the symbol that exports the data, *library*
is the loaded shared library. | .. method:: in_dll(library, name)
This method returns a ctypes type instance exported by a shared
library. *name* is the name of the symbol that exports the data, *library*
is the loaded shared library. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
cce08c80-087d-456a-a076-81217819ca2e | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,667 | supabase-export-v2 | a2c395cb0510a9fa | are not normalized or processed in any way. The function can raise :exc:`OSError` if the underlying platform APIs fail. The exact functionality is system dependent.
On most platforms, the first element of the list represents the current
executable file. It may be an empty string. | trusted_official_docs | CPython Docs | are not normalized or processed in any way. The function can raise :exc:`OSError` if the underlying platform APIs fail. The exact functionality is system dependent.
On most platforms, the first element of the list represents the current
executable file. It may be an empty string. | are not normalized or processed in any way. The function can raise :exc:`OSError` if the underlying platform APIs fail. The exact functionality is system dependent.
On most platforms, the first element of the list represents the current
executable file. It may be an empty string. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ce182aa9-9449-4d69-ae3e-c5c227469559 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,419 | supabase-export-v2 | 2ffaa78c0b9b032a | module is imported, it is searched in this table. Third-party code could play tricks with this to provide a dynamically created collection of frozen modules.
So manipulating this pointer could even prove useful. To restrict the example
size, we show only how this table can be read with :mod:`!ctypes`:: | trusted_official_docs | CPython Docs | module is imported, it is searched in this table. Third-party code could play tricks with this to provide a dynamically created collection of frozen modules.
So manipulating this pointer could even prove useful. To restrict the example
size, we show only how this table can be read with :mod:`!ctypes`:: | module is imported, it is searched in this table. Third-party code could play tricks with this to provide a dynamically created collection of frozen modules.
So manipulating this pointer could even prove useful. To restrict the example
size, we show only how this table can be read with :mod:`!ctypes`:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ce3d2d1c-0108-483d-ad05-ac637e26631a | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,191 | supabase-export-v2 | fc9915bf6b1af0f6 | .. versionchanged:: 3.3 Windows errors used to raise :exc:`WindowsError`, which is now an alias of :exc:`OSError`.
Here are some examples for Windows. Note that ``msvcrt`` is the MS standard C
library containing most standard C functions, and uses the ``cdecl`` calling
convention:: | trusted_official_docs | CPython Docs | .. versionchanged:: 3.3 Windows errors used to raise :exc:`WindowsError`, which is now an alias of :exc:`OSError`.
Here are some examples for Windows. Note that ``msvcrt`` is the MS standard C
library containing most standard C functions, and uses the ``cdecl`` calling
convention:: | .. versionchanged:: 3.3 Windows errors used to raise :exc:`WindowsError`, which is now an alias of :exc:`OSError`.
Here are some examples for Windows. Note that ``msvcrt`` is the MS standard C
library containing most standard C functions, and uses the ``cdecl`` calling
convention:: | 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.