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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3618db08-3eee-4808-81db-57277cb52da6 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,407 | supabase-export-v2 | dd850157cb702e1f | The function factories can be used as decorator factories, so we may as well write::
>>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
... 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), py_cmp_func)
py_cmp_func 5 1
py_cmp_func 33 99... | trusted_official_docs | CPython Docs | The function factories can be used as decorator factories, so we may as well write::
>>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
... 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), py_cmp_func)
py_cmp_func 5 1
py_cmp_func 33 99... | The function factories can be used as decorator factories, so we may as well write::
>>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
... 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), py_cmp_func)
py_cmp_func 5 1
py_cmp_func 33 99... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
361c4fbb-5c81-4d9d-8a69-7a5040af07c9 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,310 | supabase-export-v2 | 091f13b34d77092a | .. warning::
:mod:`!ctypes` does not support passing unions or structures with bit-fields
to functions by value. While this may work on 32-bit x86, it's not
guaranteed by the library to work in the general case. Unions and
structures with bit-fields should always be passed to functions by pointer. | trusted_official_docs | CPython Docs | .. warning::
:mod:`!ctypes` does not support passing unions or structures with bit-fields
to functions by value. While this may work on 32-bit x86, it's not
guaranteed by the library to work in the general case. Unions and
structures with bit-fields should always be passed to functions by pointer. | .. warning::
:mod:`!ctypes` does not support passing unions or structures with bit-fields
to functions by value. While this may work on 32-bit x86, it's not
guaranteed by the library to work in the general case. Unions and
structures with bit-fields should always be passed to functions by pointer. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3770b588-64e6-4422-8265-5e7849cca5ee | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,249 | supabase-export-v2 | 4c4110b0ce9f30f0 | beer\n", 42.5) Traceback (most recent call last): File "<stdin>", line 1, in <module> ctypes.ArgumentError: argument 2: TypeError: Don't know how to convert parameter 2 >>>
As has been mentioned before, all Python types except integers, strings, and
bytes objects have to be wrapped in their corresponding :mod:`!ctypes`... | trusted_official_docs | CPython Docs | beer\n", 42.5) Traceback (most recent call last): File "<stdin>", line 1, in <module> ctypes.ArgumentError: argument 2: TypeError: Don't know how to convert parameter 2 >>>
As has been mentioned before, all Python types except integers, strings, and
bytes objects have to be wrapped in their corresponding :mod:`!ctypes`... | beer\n", 42.5) Traceback (most recent call last): File "<stdin>", line 1, in <module> ctypes.ArgumentError: argument 2: TypeError: Don't know how to convert parameter 2 >>>
As has been mentioned before, all Python types except integers, strings, and
bytes objects have to be wrapped in their corresponding :mod:`!ctypes`... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3788caea-782f-4819-902c-8c454c403a64 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,248 | supabase-export-v2 | 8058f9d27f6c70dc | to the real standard output channel, *not* to :data:`sys.stdout`, so these examples will only work at the console prompt, not from within *IDLE* or *PythonWin*::
>>> printf = libc.printf
>>> printf(b"Hello, %s\n", b"World!")
Hello, World! 14
>>> printf(b"Hello, %S\n", "World!")
Hello, World! 14
>>> printf(b"%d bot... | trusted_official_docs | CPython Docs | to the real standard output channel, *not* to :data:`sys.stdout`, so these examples will only work at the console prompt, not from within *IDLE* or *PythonWin*::
>>> printf = libc.printf
>>> printf(b"Hello, %s\n", b"World!")
Hello, World! 14
>>> printf(b"Hello, %S\n", "World!")
Hello, World! 14
>>> printf(b"%d bot... | to the real standard output channel, *not* to :data:`sys.stdout`, so these examples will only work at the console prompt, not from within *IDLE* or *PythonWin*::
>>> printf = libc.printf
>>> printf(b"Hello, %s\n", b"World!")
Hello, World! 14
>>> printf(b"Hello, %S\n", "World!")
Hello, World! 14
>>> printf(b"%d bot... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
37aebdaa-ad59-4eca-81c8-5183fb6026a7 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,886 | supabase-export-v2 | e958b0863928e3fa | - On Windows: ``"ms"`` - When :attr:`~Structure._pack_` is specified: ``"ms"``. (This is deprecated; see :attr:`~Structure._pack_` documentation.) - Otherwise: ``"gcc-sysv"``
:attr:`!_layout_` must already be defined when
:attr:`~Structure._fields_` is assigned, otherwise it will have no effect. | trusted_official_docs | CPython Docs | - On Windows: ``"ms"`` - When :attr:`~Structure._pack_` is specified: ``"ms"``. (This is deprecated; see :attr:`~Structure._pack_` documentation.) - Otherwise: ``"gcc-sysv"``
:attr:`!_layout_` must already be defined when
:attr:`~Structure._fields_` is assigned, otherwise it will have no effect. | - On Windows: ``"ms"`` - When :attr:`~Structure._pack_` is specified: ``"ms"``. (This is deprecated; see :attr:`~Structure._pack_` documentation.) - Otherwise: ``"gcc-sysv"``
:attr:`!_layout_` must already be defined when
:attr:`~Structure._fields_` is assigned, otherwise it will have no effect. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
38e97b94-e952-4ec0-b392-717823983313 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,567 | supabase-export-v2 | 3c460f0067ee5c5a | accepts. For example, a :class:`c_char_p` item in the :attr:`argtypes` tuple will convert a string passed as argument into a bytes object using ctypes conversion rules.
New: It is now possible to put items in argtypes which are not ctypes
types, but each item must have a :meth:`~_CData.from_param` method which returns... | trusted_official_docs | CPython Docs | accepts. For example, a :class:`c_char_p` item in the :attr:`argtypes` tuple will convert a string passed as argument into a bytes object using ctypes conversion rules.
New: It is now possible to put items in argtypes which are not ctypes
types, but each item must have a :meth:`~_CData.from_param` method which returns... | accepts. For example, a :class:`c_char_p` item in the :attr:`argtypes` tuple will convert a string passed as argument into a bytes object using ctypes conversion rules.
New: It is now possible to put items in argtypes which are not ctypes
types, but each item must have a :meth:`~_CData.from_param` method which returns... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3986e8ff-6757-4622-8912-ffea9c610645 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,371 | supabase-export-v2 | 1147e157e1634ac9 | = (c_byte * 4)() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: incompatible types, c_byte_Array_4 instance instead of LP_c_long instance >>>
For these cases, the :func:`cast` function is handy. | trusted_official_docs | CPython Docs | = (c_byte * 4)() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: incompatible types, c_byte_Array_4 instance instead of LP_c_long instance >>>
For these cases, the :func:`cast` function is handy. | = (c_byte * 4)() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: incompatible types, c_byte_Array_4 instance instead of LP_c_long instance >>>
For these cases, the :func:`cast` function is handy. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3988b77b-3bb5-4fbb-82e7-77efca21305e | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,721 | supabase-export-v2 | 1bcdade4f7135728 | Another instance variable is exposed as :attr:`_objects`; this contains other Python objects that need to be kept alive in case the memory block contains pointers.
Common methods of ctypes data types, these are all class methods (to be
exact, they are methods of the :term:`metaclass`): | trusted_official_docs | CPython Docs | Another instance variable is exposed as :attr:`_objects`; this contains other Python objects that need to be kept alive in case the memory block contains pointers.
Common methods of ctypes data types, these are all class methods (to be
exact, they are methods of the :term:`metaclass`): | Another instance variable is exposed as :attr:`_objects`; this contains other Python objects that need to be kept alive in case the memory block contains pointers.
Common methods of ctypes data types, these are all class methods (to be
exact, they are methods of the :term:`metaclass`): | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3a4ac376-7989-483c-864b-26bdee973ef6 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,360 | supabase-export-v2 | ed71d99f3bb379c8 | .. code-block:: pycon
>>> import threading
>>> lock = threading.Lock()
>>> # Thread 1
>>> with lock:
... pointer_a.contents = 24
>>> # Thread 2
>>> with lock:
... pointer_b.contents = 42 | trusted_official_docs | CPython Docs | .. code-block:: pycon
>>> import threading
>>> lock = threading.Lock()
>>> # Thread 1
>>> with lock:
... pointer_a.contents = 24
>>> # Thread 2
>>> with lock:
... pointer_b.contents = 42 | .. code-block:: pycon
>>> import threading
>>> lock = threading.Lock()
>>> # Thread 1
>>> with lock:
... pointer_a.contents = 24
>>> # Thread 2
>>> with lock:
... pointer_b.contents = 42 | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3a5393e6-1df6-4614-97a4-2b6aa90f84c8 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,382 | supabase-export-v2 | 82144d4e9c6747ea | The straightforward translation into ctypes code would be this, but it does not work::
>>> class cell(Structure):
... _fields_ = [("name", c_char_p),
... ("next", POINTER(cell))]
... Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in cell
NameError: name 'cell' is no... | trusted_official_docs | CPython Docs | The straightforward translation into ctypes code would be this, but it does not work::
>>> class cell(Structure):
... _fields_ = [("name", c_char_p),
... ("next", POINTER(cell))]
... Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in cell
NameError: name 'cell' is no... | The straightforward translation into ctypes code would be this, but it does not work::
>>> class cell(Structure):
... _fields_ = [("name", c_char_p),
... ("next", POINTER(cell))]
... Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in cell
NameError: name 'cell' is no... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3ba6230e-cba3-40e0-91c0-00d2269103a1 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,577 | supabase-export-v2 | 83075f5724bf241a | suitable Python exception. Further, an auditing event ``ctypes.set_exception`` with argument ``code`` will be raised, allowing an audit hook to replace the exception with its own.
.. audit-event:: ctypes.call_function func_pointer,arguments foreign-functions | trusted_official_docs | CPython Docs | suitable Python exception. Further, an auditing event ``ctypes.set_exception`` with argument ``code`` will be raised, allowing an audit hook to replace the exception with its own.
.. audit-event:: ctypes.call_function func_pointer,arguments foreign-functions | suitable Python exception. Further, an auditing event ``ctypes.set_exception`` with argument ``code`` will be raised, allowing an audit hook to replace the exception with its own.
.. audit-event:: ctypes.call_function func_pointer,arguments foreign-functions | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3c1ffa4c-c4d8-48d8-881c-f7f383243fd3 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,299 | supabase-export-v2 | c17e323660e869cc | The field type must be a :mod:`!ctypes` type like :class:`c_int`, or any other derived :mod:`!ctypes` type: structure, union, array, pointer.
Here is a simple example of a POINT structure, which contains two integers named
*x* and *y*, and also shows how to initialize a structure in the constructor:: | trusted_official_docs | CPython Docs | The field type must be a :mod:`!ctypes` type like :class:`c_int`, or any other derived :mod:`!ctypes` type: structure, union, array, pointer.
Here is a simple example of a POINT structure, which contains two integers named
*x* and *y*, and also shows how to initialize a structure in the constructor:: | The field type must be a :mod:`!ctypes` type like :class:`c_int`, or any other derived :mod:`!ctypes` type: structure, union, array, pointer.
Here is a simple example of a POINT structure, which contains two integers named
*x* and *y*, and also shows how to initialize a structure in the constructor:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3e5d67ba-7788-4c4d-83d6-c643c59f37c6 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,455 | supabase-export-v2 | b7bb2563ce402225 | lock` is released before calling any function exported by these libraries, and reacquired afterwards. For different function behavior, use a subclass: :py:class:`~ctypes.OleDLL`, :py:class:`~ctypes.WinDLL`, or :py:class:`~ctypes.PyDLL`.
If you have an existing :py:attr:`handle <ctypes.CDLL._handle>` to an already
load... | trusted_official_docs | CPython Docs | lock` is released before calling any function exported by these libraries, and reacquired afterwards. For different function behavior, use a subclass: :py:class:`~ctypes.OleDLL`, :py:class:`~ctypes.WinDLL`, or :py:class:`~ctypes.PyDLL`.
If you have an existing :py:attr:`handle <ctypes.CDLL._handle>` to an already
load... | lock` is released before calling any function exported by these libraries, and reacquired afterwards. For different function behavior, use a subclass: :py:class:`~ctypes.OleDLL`, :py:class:`~ctypes.WinDLL`, or :py:class:`~ctypes.PyDLL`.
If you have an existing :py:attr:`handle <ctypes.CDLL._handle>` to an already
load... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
3ee3875f-60d4-4c11-bf2a-fc669ff477df | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,414 | supabase-export-v2 | 3703591410ae4397 | functions, they also export variables. An example in the Python library itself is the :c:data:`Py_Version`, Python runtime version number encoded in a single constant integer.
:mod:`!ctypes` can access values like this with the :meth:`~_CData.in_dll` class methods of
the type. *pythonapi* is a predefined symbol giving ... | trusted_official_docs | CPython Docs | functions, they also export variables. An example in the Python library itself is the :c:data:`Py_Version`, Python runtime version number encoded in a single constant integer.
:mod:`!ctypes` can access values like this with the :meth:`~_CData.in_dll` class methods of
the type. *pythonapi* is a predefined symbol giving ... | functions, they also export variables. An example in the Python library itself is the :c:data:`Py_Version`, Python runtime version number encoded in a single constant integer.
:mod:`!ctypes` can access values like this with the :meth:`~_CData.in_dll` class methods of
the type. *pythonapi* is a predefined symbol giving ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
402643dc-97a2-48df-8fcf-934cecf6376a | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,617 | supabase-export-v2 | a32548ec98b19870 | function retrieves the dimensions of a specified window by copying them into ``RECT`` structure that the caller has to supply. Here is the C declaration::
WINUSERAPI BOOL WINAPI
GetWindowRect(
HWND hWnd,
LPRECT lpRect); | trusted_official_docs | CPython Docs | function retrieves the dimensions of a specified window by copying them into ``RECT`` structure that the caller has to supply. Here is the C declaration::
WINUSERAPI BOOL WINAPI
GetWindowRect(
HWND hWnd,
LPRECT lpRect); | function retrieves the dimensions of a specified window by copying them into ``RECT`` structure that the caller has to supply. Here is the C declaration::
WINUSERAPI BOOL WINAPI
GetWindowRect(
HWND hWnd,
LPRECT lpRect); | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
40a371c7-3525-4340-9ed5-a75b797017dc | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,221 | supabase-export-v2 | eadcb3ab8225fe2e | find out the correct calling convention you have to look into the C header file or the documentation for the function you want to call.
On Windows, :mod:`!ctypes` uses win32 structured exception handling to prevent
crashes from general protection faults when functions are called with invalid
argument values:: | trusted_official_docs | CPython Docs | find out the correct calling convention you have to look into the C header file or the documentation for the function you want to call.
On Windows, :mod:`!ctypes` uses win32 structured exception handling to prevent
crashes from general protection faults when functions are called with invalid
argument values:: | find out the correct calling convention you have to look into the C header file or the documentation for the function you want to call.
On Windows, :mod:`!ctypes` uses win32 structured exception handling to prevent
crashes from general protection faults when functions are called with invalid
argument values:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4222d830-d0d0-4e09-92e7-7e0977a65c4e | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,319 | supabase-export-v2 | 1d29640fcacddf3b | = [("first_16", c_int, 16), ... ("second_16", c_int, 16)] ... >>> print(Int.first_16) <ctypes.CField 'first_16' type=c_int, ofs=0, bit_size=16, bit_offset=0> >>> print(Int.second_16) <ctypes.CField 'second_16' type=c_int, ofs=0, bit_size=16, bit_offset=16>
It is important to note that bit field allocation and layout in... | trusted_official_docs | CPython Docs | = [("first_16", c_int, 16), ... ("second_16", c_int, 16)] ... >>> print(Int.first_16) <ctypes.CField 'first_16' type=c_int, ofs=0, bit_size=16, bit_offset=0> >>> print(Int.second_16) <ctypes.CField 'second_16' type=c_int, ofs=0, bit_size=16, bit_offset=16>
It is important to note that bit field allocation and layout in... | = [("first_16", c_int, 16), ... ("second_16", c_int, 16)] ... >>> print(Int.first_16) <ctypes.CField 'first_16' type=c_int, ofs=0, bit_size=16, bit_offset=0> >>> print(Int.second_16) <ctypes.CField 'second_16' type=c_int, ofs=0, bit_size=16, bit_offset=16>
It is important to note that bit field allocation and layout in... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
43399339-78b7-411c-87c4-ce3b5ac92d10 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,668 | supabase-export-v2 | 7906f79fdfb321fa | On most platforms, the first element of the list represents the current executable file. It may be an empty string.
.. availability:: Windows, macOS, iOS, glibc, BSD libc, musl
.. versionadded:: 3.14 | trusted_official_docs | CPython Docs | On most platforms, the first element of the list represents the current executable file. It may be an empty string.
.. availability:: Windows, macOS, iOS, glibc, BSD libc, musl
.. versionadded:: 3.14 | On most platforms, the first element of the list represents the current executable file. It may be an empty string.
.. availability:: Windows, macOS, iOS, glibc, BSD libc, musl
.. versionadded:: 3.14 | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
43e239b9-db6c-4da1-b766-d25885c0ec4f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,599 | supabase-export-v2 | 135076bfe35d5fdd | 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.
COM methods use a special calling convention: They require a pointer to
the COM interface as first argument, in addition to those parameters that
are specified in th... | trusted_official_docs | CPython Docs | 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.
COM methods use a special calling convention: They require a pointer to
the COM interface as first argument, in addition to those parameters that
are specified in th... | 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.
COM methods use a special calling convention: They require a pointer to
the COM interface as first argument, in addition to those parameters that
are specified in th... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
43faa342-ee1c-4f32-a4a0-2ceda87ebee3 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,595 | supabase-export-v2 | 27a20144c8dfbeb1 | .. function:: prototype(func_spec[, paramflags]) :noindex: :module:
Returns a foreign function exported by a shared library. *func_spec* must
be a 2-tuple ``(name_or_ordinal, library)``. The first item is the name of
the exported function as string, or the ordinal of the exported function
as small integer. The secon... | trusted_official_docs | CPython Docs | .. function:: prototype(func_spec[, paramflags]) :noindex: :module:
Returns a foreign function exported by a shared library. *func_spec* must
be a 2-tuple ``(name_or_ordinal, library)``. The first item is the name of
the exported function as string, or the ordinal of the exported function
as small integer. The secon... | .. function:: prototype(func_spec[, paramflags]) :noindex: :module:
Returns a foreign function exported by a shared library. *func_spec* must
be a 2-tuple ``(name_or_ordinal, library)``. The first item is the name of
the exported function as string, or the ordinal of the exported function
as small integer. The secon... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
480278db-904f-4994-8137-1435577cacf7 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,893 | supabase-export-v2 | dfff5f98544a1618 | class TYPEDESC(Structure): _anonymous_ = ("u",) _fields_ = [("u", _U), ("vt", VARTYPE)]
The ``TYPEDESC`` structure describes a COM data type, the ``vt`` field
specifies which one of the union fields is valid. Since the ``u`` field
is defined as anonymous field, it is now possible to access the members
directly off t... | trusted_official_docs | CPython Docs | class TYPEDESC(Structure): _anonymous_ = ("u",) _fields_ = [("u", _U), ("vt", VARTYPE)]
The ``TYPEDESC`` structure describes a COM data type, the ``vt`` field
specifies which one of the union fields is valid. Since the ``u`` field
is defined as anonymous field, it is now possible to access the members
directly off t... | class TYPEDESC(Structure): _anonymous_ = ("u",) _fields_ = [("u", _U), ("vt", VARTYPE)]
The ``TYPEDESC`` structure describes a COM data type, the ``vt`` field
specifies which one of the union fields is valid. Since the ``u`` field
is defined as anonymous field, it is now possible to access the members
directly off t... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
49e1752d-f14a-4ae7-9ea0-8179df9dbb26 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,654 | supabase-export-v2 | 446ec7251a6bdb52 | >>> 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: byte string too long
.. audit-event:: ctypes.create_string_buffer init... | trusted_official_docs | CPython Docs | >>> 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: byte string too long
.. audit-event:: ctypes.create_string_buffer init... | >>> 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: byte string too long
.. audit-event:: ctypes.create_string_buffer init... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4b0b15a3-63f1-4252-b65a-02bbda58f4e1 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,185 | supabase-export-v2 | b13d190936c1a026 | ctypes tutorial ---------------
Note: Some code samples reference the ctypes :class:`c_int` type. On platforms
where ``sizeof(long) == sizeof(int)`` it is an alias to :class:`c_long`. So, you should not be confused if :class:`c_long` is printed if you would expect
:class:`c_int` --- they are actually the same type. | trusted_official_docs | CPython Docs | ctypes tutorial ---------------
Note: Some code samples reference the ctypes :class:`c_int` type. On platforms
where ``sizeof(long) == sizeof(int)`` it is an alias to :class:`c_long`. So, you should not be confused if :class:`c_long` is printed if you would expect
:class:`c_int` --- they are actually the same type. | ctypes tutorial ---------------
Note: Some code samples reference the ctypes :class:`c_int` type. On platforms
where ``sizeof(long) == sizeof(int)`` it is an alias to :class:`c_long`. So, you should not be confused if :class:`c_long` is printed if you would expect
:class:`c_int` --- they are actually the same type. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4b15341c-95e3-4bb5-bbd3-bcc1ce4dd905 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,685 | supabase-export-v2 | 3843303aad99f952 | .. function:: memset(dst, c, count)
Same as the standard C memset library function: fills the memory block at
address *dst* with *count* bytes of value *c*. *dst* must be an integer
specifying an address, or a ctypes instance. | trusted_official_docs | CPython Docs | .. function:: memset(dst, c, count)
Same as the standard C memset library function: fills the memory block at
address *dst* with *count* bytes of value *c*. *dst* must be an integer
specifying an address, or a ctypes instance. | .. function:: memset(dst, c, count)
Same as the standard C memset library function: fills the memory block at
address *dst* with *count* bytes of value *c*. *dst* must be an integer
specifying an address, or a ctypes instance. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4c0de286-8ac5-485b-9a0f-873cd57298ed | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,878 | supabase-export-v2 | c339c21fa48f4637 | be negative. The effect is equivalent to ``__attribute__((aligned(N)))`` on GCC or ``#pragma align(N)`` on MSVC, except :mod:`!ctypes` may allow values that the compiler would reject.
:attr:`!_align_` can only *increase* a structure's alignment
requirements. Setting it to 0 or 1 has no effect. | trusted_official_docs | CPython Docs | be negative. The effect is equivalent to ``__attribute__((aligned(N)))`` on GCC or ``#pragma align(N)`` on MSVC, except :mod:`!ctypes` may allow values that the compiler would reject.
:attr:`!_align_` can only *increase* a structure's alignment
requirements. Setting it to 0 or 1 has no effect. | be negative. The effect is equivalent to ``__attribute__((aligned(N)))`` on GCC or ``#pragma align(N)`` on MSVC, except :mod:`!ctypes` may allow values that the compiler would reject.
:attr:`!_align_` can only *increase* a structure's alignment
requirements. Setting it to 0 or 1 has no effect. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4c5ad468-3052-4429-a431-6eadaca9a294 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,413 | supabase-export-v2 | dc16af7163db5685 | Accessing values exported from dlls ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some shared libraries not only export functions, they also export variables. An
example in the Python library itself is the :c:data:`Py_Version`, Python
runtime version number encoded in a single constant integer. | trusted_official_docs | CPython Docs | Accessing values exported from dlls ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some shared libraries not only export functions, they also export variables. An
example in the Python library itself is the :c:data:`Py_Version`, Python
runtime version number encoded in a single constant integer. | Accessing values exported from dlls ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some shared libraries not only export functions, they also export variables. An
example in the Python library itself is the :c:data:`Py_Version`, Python
runtime version number encoded in a single constant integer. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4c913833-c199-4e41-8180-eba3c9085580 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,235 | supabase-export-v2 | 29f3b733d9417617 | All these types can be created by calling them with an optional initializer of the correct type and value::
>>> c_int()
c_long(0)
>>> c_wchar_p("Hello, World")
c_wchar_p(140018365411392)
>>> c_ushort(-3)
c_ushort(65533)
>>> | trusted_official_docs | CPython Docs | All these types can be created by calling them with an optional initializer of the correct type and value::
>>> c_int()
c_long(0)
>>> c_wchar_p("Hello, World")
c_wchar_p(140018365411392)
>>> c_ushort(-3)
c_ushort(65533)
>>> | All these types can be created by calling them with an optional initializer of the correct type and value::
>>> c_int()
c_long(0)
>>> c_wchar_p("Hello, World")
c_wchar_p(140018365411392)
>>> c_ushort(-3)
c_ushort(65533)
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4d1b74fa-d8b1-4874-af45-1adf0739e644 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,798 | supabase-export-v2 | fc2bece02f1bc5bb | .. class:: c_longlong
Represents the C :c:expr:`signed long long` datatype. The constructor accepts
an optional integer initializer; no overflow checking is done. On platforms where ``sizeof(long long) == sizeof(long)`` it is an alias
to :class:`c_long`. | trusted_official_docs | CPython Docs | .. class:: c_longlong
Represents the C :c:expr:`signed long long` datatype. The constructor accepts
an optional integer initializer; no overflow checking is done. On platforms where ``sizeof(long long) == sizeof(long)`` it is an alias
to :class:`c_long`. | .. class:: c_longlong
Represents the C :c:expr:`signed long long` datatype. The constructor accepts
an optional integer initializer; no overflow checking is done. On platforms where ``sizeof(long long) == sizeof(long)`` it is an alias
to :class:`c_long`. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4d8e47d1-5804-45cb-8d5c-84d702e39e37 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,549 | supabase-export-v2 | 2b9e84b4c12c4090 | function, which calls the different APIs provided by the various platforms to help determine which shared libraries have already been loaded into the current process.
The exact output of this function will be system dependent. On most platforms,
the first entry of this list represents the current process itself, which ... | trusted_official_docs | CPython Docs | function, which calls the different APIs provided by the various platforms to help determine which shared libraries have already been loaded into the current process.
The exact output of this function will be system dependent. On most platforms,
the first entry of this list represents the current process itself, which ... | function, which calls the different APIs provided by the various platforms to help determine which shared libraries have already been loaded into the current process.
The exact output of this function will be system dependent. On most platforms,
the first entry of this list represents the current process itself, which ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4dd02f85-4a05-4d48-8e34-c9fd8f170eab | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,215 | supabase-export-v2 | 09c028e0e4d3433c | >>> print(libc.rand()) # doctest: +SKIP 1804289383
On 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):: | trusted_official_docs | CPython Docs | >>> print(libc.rand()) # doctest: +SKIP 1804289383
On 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(libc.rand()) # doctest: +SKIP 1804289383
On 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):: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4f186c11-3a68-479a-be5f-78bb94523dae | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,369 | supabase-export-v2 | ab9ace295b82ad42 | .. XXX list other conversions...
Sometimes you have instances of incompatible types. In C, you can cast one type
into another type. :mod:`!ctypes` provides a :func:`cast` function which can be
used in the same way. The ``Bar`` structure defined above accepts
``POINTER(c_int)`` pointers or :class:`c_int` arrays for its ... | trusted_official_docs | CPython Docs | .. XXX list other conversions...
Sometimes you have instances of incompatible types. In C, you can cast one type
into another type. :mod:`!ctypes` provides a :func:`cast` function which can be
used in the same way. The ``Bar`` structure defined above accepts
``POINTER(c_int)`` pointers or :class:`c_int` arrays for its ... | .. XXX list other conversions...
Sometimes you have instances of incompatible types. In C, you can cast one type
into another type. :mod:`!ctypes` provides a :func:`cast` function which can be
used in the same way. The ``Bar`` structure defined above accepts
``POINTER(c_int)`` pointers or :class:`c_int` arrays for its ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
4fb5e4ec-a73a-4e55-b4b1-b2b145b892ff | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,222 | supabase-export-v2 | d3fd6d4fdf5d97aa | On Windows, :mod:`!ctypes` uses win32 structured exception handling to prevent crashes from general protection faults when functions are called with invalid argument values::
>>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: e... | trusted_official_docs | CPython Docs | On Windows, :mod:`!ctypes` uses win32 structured exception handling to prevent crashes from general protection faults when functions are called with invalid argument values::
>>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: e... | On Windows, :mod:`!ctypes` uses win32 structured exception handling to prevent crashes from general protection faults when functions are called with invalid argument values::
>>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: e... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
50aa339e-a5de-43b2-844a-5b7b019a5f04 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,209 | supabase-export-v2 | 44dab6ae3c097354 | >>> getattr(cdll.msvcrt, "??2@YAPAXI@Z") # doctest: +WINDOWS <_FuncPtr object at 0x...> >>>
On 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:: | trusted_official_docs | CPython Docs | >>> getattr(cdll.msvcrt, "??2@YAPAXI@Z") # doctest: +WINDOWS <_FuncPtr object at 0x...> >>>
On 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:: | >>> getattr(cdll.msvcrt, "??2@YAPAXI@Z") # doctest: +WINDOWS <_FuncPtr object at 0x...> >>>
On 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:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
50bab16f-3084-4e15-a3d7-25842cbef33d | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,270 | supabase-export-v2 | 83edfe7d1f1413d9 | in <module> ctypes.ArgumentError: argument 2: TypeError: 'int' object cannot be interpreted as ctypes.c_char_p >>> printf(b"%s %d %f\n", b"X", 2, 3) X 2 3.000000 13 >>>
If you have defined your own classes which you pass to function calls, you have
to implement a :meth:`~_CData.from_param` class method for them to be a... | trusted_official_docs | CPython Docs | in <module> ctypes.ArgumentError: argument 2: TypeError: 'int' object cannot be interpreted as ctypes.c_char_p >>> printf(b"%s %d %f\n", b"X", 2, 3) X 2 3.000000 13 >>>
If you have defined your own classes which you pass to function calls, you have
to implement a :meth:`~_CData.from_param` class method for them to be a... | in <module> ctypes.ArgumentError: argument 2: TypeError: 'int' object cannot be interpreted as ctypes.c_char_p >>> printf(b"%s %d %f\n", b"X", 2, 3) X 2 3.000000 13 >>>
If you have defined your own classes which you pass to function calls, you have
to implement a :meth:`~_CData.from_param` class method for them to be a... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
50bdee21-065c-40eb-9c1b-54a80ee48724 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,234 | supabase-export-v2 | e4685f904d0c7aa0 | - :py:class:`complex` - ``'F'`` * - :class:`c_double_complex` - :c:expr:`double complex` - :py:class:`complex` - ``'D'`` * - :class:`c_longdouble_complex` - :c:expr:`long double complex` - :py:class:`complex` - ``'G'``
All these types can be created by calling them with an optional initializer of
the correct type and v... | trusted_official_docs | CPython Docs | - :py:class:`complex` - ``'F'`` * - :class:`c_double_complex` - :c:expr:`double complex` - :py:class:`complex` - ``'D'`` * - :class:`c_longdouble_complex` - :c:expr:`long double complex` - :py:class:`complex` - ``'G'``
All these types can be created by calling them with an optional initializer of
the correct type and v... | - :py:class:`complex` - ``'F'`` * - :class:`c_double_complex` - :c:expr:`double complex` - :py:class:`complex` - ``'D'`` * - :class:`c_longdouble_complex` - :c:expr:`long double complex` - :py:class:`complex` - ``'G'``
All these types can be created by calling them with an optional initializer of
the correct type and v... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
50f2e271-27df-465e-a023-e66233cd0228 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,194 | supabase-export-v2 | 9c842a2fe697366c | Windows appends the usual ``.dll`` file suffix automatically.
.. note::
Accessing the standard C library through ``cdll.msvcrt`` will use an
outdated version of the library that may be incompatible with the one
being used by Python. Where possible, use native Python functionality,
or else import and use the ``msvcr... | trusted_official_docs | CPython Docs | Windows appends the usual ``.dll`` file suffix automatically.
.. note::
Accessing the standard C library through ``cdll.msvcrt`` will use an
outdated version of the library that may be incompatible with the one
being used by Python. Where possible, use native Python functionality,
or else import and use the ``msvcr... | Windows appends the usual ``.dll`` file suffix automatically.
.. note::
Accessing the standard C library through ``cdll.msvcrt`` will use an
outdated version of the library that may be incompatible with the one
being used by Python. Where possible, use native Python functionality,
or else import and use the ``msvcr... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
524f5761-02c4-4435-8218-232d8ddc4ab6 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,640 | supabase-export-v2 | 3d67d6de530cf56a | If *src* is not ``NULL``, its ``AddRef`` method is called, incrementing the reference count.
In contrast, the reference count of *dst* will not be decremented before
assigning the new value. Unless *dst* is ``NULL``, the caller is responsible
for decrementing the reference count by calling its ``Release`` method when... | trusted_official_docs | CPython Docs | If *src* is not ``NULL``, its ``AddRef`` method is called, incrementing the reference count.
In contrast, the reference count of *dst* will not be decremented before
assigning the new value. Unless *dst* is ``NULL``, the caller is responsible
for decrementing the reference count by calling its ``Release`` method when... | If *src* is not ``NULL``, its ``AddRef`` method is called, incrementing the reference count.
In contrast, the reference count of *dst* will not be decremented before
assigning the new value. Unless *dst* is ``NULL``, the caller is responsible
for decrementing the reference count by calling its ``Release`` method when... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5584e59c-9841-4598-aefd-c90b3106df18 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,756 | supabase-export-v2 | bc20bce4f3775c05 | each time. :mod:`!ctypes` does *not* implement original object return, always a new object is constructed. The same is true for all other ctypes object instances.
Each subclass has a class attribute: | trusted_official_docs | CPython Docs | each time. :mod:`!ctypes` does *not* implement original object return, always a new object is constructed. The same is true for all other ctypes object instances.
Each subclass has a class attribute: | each time. :mod:`!ctypes` does *not* implement original object return, always a new object is constructed. The same is true for all other ctypes object instances.
Each subclass has a class attribute: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
560862ed-c2d5-429a-b4d5-467c493d089d | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,220 | supabase-export-v2 | 28c3b9b2cf1eb116 | +WINDOWS Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Procedure probably called with too many arguments (4 bytes in excess) >>>
To find out the correct calling convention you have to look into the C header
file or the documentation for the function you want to call. | trusted_official_docs | CPython Docs | +WINDOWS Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Procedure probably called with too many arguments (4 bytes in excess) >>>
To find out the correct calling convention you have to look into the C header
file or the documentation for the function you want to call. | +WINDOWS Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Procedure probably called with too many arguments (4 bytes in excess) >>>
To find out the correct calling convention you have to look into the C header
file or the documentation for the function you want to call. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
56d1de29-7a96-49c1-85f1-2fce7076bbc7 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,330 | supabase-export-v2 | 5bd6004d2c60ceb7 | Initializers of the correct type can also be specified::
>>> from ctypes import *
>>> TenIntegers = c_int * 10
>>> ii = TenIntegers(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
>>> print(ii)
<c_long_Array_10 object at 0x...>
>>> for i in ii: print(i, end=" ")
... 1 2 3 4 5 6 7 8 9 10
>>> | trusted_official_docs | CPython Docs | Initializers of the correct type can also be specified::
>>> from ctypes import *
>>> TenIntegers = c_int * 10
>>> ii = TenIntegers(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
>>> print(ii)
<c_long_Array_10 object at 0x...>
>>> for i in ii: print(i, end=" ")
... 1 2 3 4 5 6 7 8 9 10
>>> | Initializers of the correct type can also be specified::
>>> from ctypes import *
>>> TenIntegers = c_int * 10
>>> ii = TenIntegers(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
>>> print(ii)
<c_long_Array_10 object at 0x...>
>>> for i in ii: print(i, end=" ")
... 1 2 3 4 5 6 7 8 9 10
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
573531ef-0282-4654-b57b-21f0cdbafd8a | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,311 | supabase-export-v2 | ecb49005dfde4a60 | it's not guaranteed by the library to work in the general case. Unions and structures with bit-fields should always be passed to functions by pointer.
Structure/union layout, alignment and byte order
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | trusted_official_docs | CPython Docs | it's not guaranteed by the library to work in the general case. Unions and structures with bit-fields should always be passed to functions by pointer.
Structure/union layout, alignment and byte order
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | it's not guaranteed by the library to work in the general case. Unions and structures with bit-fields should always be passed to functions by pointer.
Structure/union layout, alignment and byte order
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
57e47065-edfc-4f31-992c-cab975809559 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,409 | supabase-export-v2 | 59edc5c8d98849a7 | .. note::
Make sure you keep references to :func:`CFUNCTYPE` objects as long as they
are used from C code. :mod:`!ctypes` doesn't, and if you don't, they may be
garbage collected, crashing your program when a callback is made. | trusted_official_docs | CPython Docs | .. note::
Make sure you keep references to :func:`CFUNCTYPE` objects as long as they
are used from C code. :mod:`!ctypes` doesn't, and if you don't, they may be
garbage collected, crashing your program when a callback is made. | .. note::
Make sure you keep references to :func:`CFUNCTYPE` objects as long as they
are used from C code. :mod:`!ctypes` doesn't, and if you don't, they may be
garbage collected, crashing your program when a callback is made. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
58ae5a0c-a6e8-4fa3-8e94-df2416d81b1a | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,373 | supabase-export-v2 | b7b802ceb7d113a7 | some kind, and a ctypes pointer type. It returns an instance of the second argument, which references the same memory block as the first argument::
>>> a = (c_byte * 4)()
>>> cast(a, POINTER(c_int))
<ctypes.LP_c_long object at ...>
>>> | trusted_official_docs | CPython Docs | some kind, and a ctypes pointer type. It returns an instance of the second argument, which references the same memory block as the first argument::
>>> a = (c_byte * 4)()
>>> cast(a, POINTER(c_int))
<ctypes.LP_c_long object at ...>
>>> | some kind, and a ctypes pointer type. It returns an instance of the second argument, which references the same memory block as the first argument::
>>> a = (c_byte * 4)()
>>> cast(a, POINTER(c_int))
<ctypes.LP_c_long object at ...>
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
59560e80-2c15-4161-8e20-190dc3c336fb | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,385 | supabase-export-v2 | 44a222313768606c | >>> from ctypes import * >>> class cell(Structure): ... pass ... >>> cell._fields_ = [("name", c_char_p), ... ("next", POINTER(cell))] >>>
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:: | trusted_official_docs | CPython Docs | >>> from ctypes import * >>> class cell(Structure): ... pass ... >>> cell._fields_ = [("name", c_char_p), ... ("next", POINTER(cell))] >>>
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:: | >>> from ctypes import * >>> class cell(Structure): ... pass ... >>> cell._fields_ = [("name", c_char_p), ... ("next", POINTER(cell))] >>>
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:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
59a65f7f-c2c2-4456-9b54-04346658a9f6 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,620 | supabase-export-v2 | 31f67e987a86c96a | ctypes.wintypes import BOOL, HWND, RECT >>> prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT)) >>> paramflags = (1, "hwnd"), (2, "lprect") >>> GetWindowRect = prototype(("GetWindowRect", windll.user32), paramflags) >>>
Functions with output parameters will automatically return the output parameter
value if there is a s... | trusted_official_docs | CPython Docs | ctypes.wintypes import BOOL, HWND, RECT >>> prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT)) >>> paramflags = (1, "hwnd"), (2, "lprect") >>> GetWindowRect = prototype(("GetWindowRect", windll.user32), paramflags) >>>
Functions with output parameters will automatically return the output parameter
value if there is a s... | ctypes.wintypes import BOOL, HWND, RECT >>> prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT)) >>> paramflags = (1, "hwnd"), (2, "lprect") >>> GetWindowRect = prototype(("GetWindowRect", windll.user32), paramflags) >>>
Functions with output parameters will automatically return the output parameter
value if there is a s... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5a40229b-dca9-4f1d-9de6-e92052eb1a5d | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,298 | supabase-export-v2 | 4bf6daf7072f3b5c | the :mod:`!ctypes` module. Each subclass must define a :attr:`~Structure._fields_` attribute. :attr:`!_fields_` must be a list of *2-tuples*, containing a *field name* and a *field type*.
The field type must be a :mod:`!ctypes` type like :class:`c_int`, or any other
derived :mod:`!ctypes` type: structure, union, array,... | trusted_official_docs | CPython Docs | the :mod:`!ctypes` module. Each subclass must define a :attr:`~Structure._fields_` attribute. :attr:`!_fields_` must be a list of *2-tuples*, containing a *field name* and a *field type*.
The field type must be a :mod:`!ctypes` type like :class:`c_int`, or any other
derived :mod:`!ctypes` type: structure, union, array,... | the :mod:`!ctypes` module. Each subclass must define a :attr:`~Structure._fields_` attribute. :attr:`!_fields_` must be a list of *2-tuples*, containing a *field name* and a *field type*.
The field type must be a :mod:`!ctypes` type like :class:`c_int`, or any other
derived :mod:`!ctypes` type: structure, union, array,... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5b15e2dd-c0e2-4ae1-8b48-e6da0c92c8b5 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,877 | supabase-export-v2 | 0b0a25a0c043c13a | An optional small integer that allows increasing the alignment of the structure when being packed or unpacked to/from memory.
The value must not be negative. The effect is equivalent to ``__attribute__((aligned(N)))`` on GCC
or ``#pragma align(N)`` on MSVC, except :mod:`!ctypes` may allow
values that the compiler wou... | trusted_official_docs | CPython Docs | An optional small integer that allows increasing the alignment of the structure when being packed or unpacked to/from memory.
The value must not be negative. The effect is equivalent to ``__attribute__((aligned(N)))`` on GCC
or ``#pragma align(N)`` on MSVC, except :mod:`!ctypes` may allow
values that the compiler wou... | An optional small integer that allows increasing the alignment of the structure when being packed or unpacked to/from memory.
The value must not be negative. The effect is equivalent to ``__attribute__((aligned(N)))`` on GCC
or ``#pragma align(N)`` on MSVC, except :mod:`!ctypes` may allow
values that the compiler wou... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5b34d7db-db5f-428c-b669-9bb34cb9e65b | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,456 | supabase-export-v2 | bcf7e92f8854e6c7 | library in a new :py:class:`!CDLL` object. In this case, *name* is only used to set the :py:attr:`~ctypes.CDLL._name` attribute, but it may be adjusted and/or validated.
If *handle* is ``None``, the underlying platform's :manpage:`dlopen(3)` or
`LoadLibraryExW`_ function is used to load the library into
the process, ... | trusted_official_docs | CPython Docs | library in a new :py:class:`!CDLL` object. In this case, *name* is only used to set the :py:attr:`~ctypes.CDLL._name` attribute, but it may be adjusted and/or validated.
If *handle* is ``None``, the underlying platform's :manpage:`dlopen(3)` or
`LoadLibraryExW`_ function is used to load the library into
the process, ... | library in a new :py:class:`!CDLL` object. In this case, *name* is only used to set the :py:attr:`~ctypes.CDLL._name` attribute, but it may be adjusted and/or validated.
If *handle* is ``None``, the underlying platform's :manpage:`dlopen(3)` or
`LoadLibraryExW`_ function is used to load the library into
the process, ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5bf5d452-ed95-4e5a-ae4d-be0f2d196206 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,443 | supabase-export-v2 | cbfd64024c2cf6ba | The memory block cannot be made smaller than the natural memory block specified by the objects type, a :exc:`ValueError` is raised if this is tried::
>>> short_array = (c_short * 4)()
>>> print(sizeof(short_array))
8
>>> resize(short_array, 4)
Traceback (most recent call last):
... ValueError: minimum size is 8
>... | trusted_official_docs | CPython Docs | The memory block cannot be made smaller than the natural memory block specified by the objects type, a :exc:`ValueError` is raised if this is tried::
>>> short_array = (c_short * 4)()
>>> print(sizeof(short_array))
8
>>> resize(short_array, 4)
Traceback (most recent call last):
... ValueError: minimum size is 8
>... | The memory block cannot be made smaller than the natural memory block specified by the objects type, a :exc:`ValueError` is raised if this is tried::
>>> short_array = (c_short * 4)()
>>> print(sizeof(short_array))
8
>>> resize(short_array, 4)
Traceback (most recent call last):
... ValueError: minimum size is 8
>... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5e1e6167-2291-4ceb-89b6-1557394459f7 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,197 | supabase-export-v2 | e869e3749f807ddb | For example, on Linux::
>>> cdll.LoadLibrary("libc.so.6") # doctest: +LINUX
<CDLL 'libc.so.6', handle ... at ...>
>>> libc = CDLL("libc.so.6") # doctest: +LINUX
>>> libc # doctest: +LINUX
<CDLL 'libc.so.6', handle ... at ...>
>>> | trusted_official_docs | CPython Docs | For example, on Linux::
>>> cdll.LoadLibrary("libc.so.6") # doctest: +LINUX
<CDLL 'libc.so.6', handle ... at ...>
>>> libc = CDLL("libc.so.6") # doctest: +LINUX
>>> libc # doctest: +LINUX
<CDLL 'libc.so.6', handle ... at ...>
>>> | For example, on Linux::
>>> cdll.LoadLibrary("libc.so.6") # doctest: +LINUX
<CDLL 'libc.so.6', handle ... at ...>
>>> libc = CDLL("libc.so.6") # doctest: +LINUX
>>> libc # doctest: +LINUX
<CDLL 'libc.so.6', handle ... at ...>
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5e9e60da-b5d3-47b6-bd73-3b73268cb567 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,525 | supabase-export-v2 | 2e4170363b5cb8e9 | to match it. However, as backwards compatibility concerns make it difficult to adjust its behavior for new platforms and configurations, the function is :term:`soft deprecated`.
If wrapping a shared library with :mod:`!ctypes`, consider determining the
shared library name at development time, and hardcoding it into the... | trusted_official_docs | CPython Docs | to match it. However, as backwards compatibility concerns make it difficult to adjust its behavior for new platforms and configurations, the function is :term:`soft deprecated`.
If wrapping a shared library with :mod:`!ctypes`, consider determining the
shared library name at development time, and hardcoding it into the... | to match it. However, as backwards compatibility concerns make it difficult to adjust its behavior for new platforms and configurations, the function is :term:`soft deprecated`.
If wrapping a shared library with :mod:`!ctypes`, consider determining the
shared library name at development time, and hardcoding it into the... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5eb29d9f-40b0-4acb-84ba-2b1669aee25b | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,460 | supabase-export-v2 | 2273081f02d471e7 | is called with ``NULL``, which opens the main program as a "library". (Some systems do the same is *name* is empty; ``None``/``NULL`` is more portable.)
.. admonition:: CPython implementation detail | trusted_official_docs | CPython Docs | is called with ``NULL``, which opens the main program as a "library". (Some systems do the same is *name* is empty; ``None``/``NULL`` is more portable.)
.. admonition:: CPython implementation detail | is called with ``NULL``, which opens the main program as a "library". (Some systems do the same is *name* is empty; ``None``/``NULL`` is more portable.)
.. admonition:: CPython implementation detail | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5f58c463-fc8c-4267-a963-8fbba3383d6d | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,955 | supabase-export-v2 | 2d0efafa850d26ec | The 5-tuple ``(descr, source, helpfile, helpcontext, progid)``.
*descr* is the textual description. *source* is the language-dependent
``ProgID`` for the class or application that raised the error. *helpfile*
is the path of the help file. *helpcontext* is the help context
identifier. *progid* is the ``ProgID`` of th... | trusted_official_docs | CPython Docs | The 5-tuple ``(descr, source, helpfile, helpcontext, progid)``.
*descr* is the textual description. *source* is the language-dependent
``ProgID`` for the class or application that raised the error. *helpfile*
is the path of the help file. *helpcontext* is the help context
identifier. *progid* is the ``ProgID`` of th... | The 5-tuple ``(descr, source, helpfile, helpcontext, progid)``.
*descr* is the textual description. *source* is the language-dependent
``ProgID`` for the class or application that raised the error. *helpfile*
is the path of the help file. *helpcontext* is the help context
identifier. *progid* is the ``ProgID`` of th... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5f7e2a10-a4e8-453e-a060-7b6fe772c452 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,429 | supabase-export-v2 | 9fba8ae4412c8a17 | Consider the following example::
>>> from ctypes import *
>>> class POINT(Structure):
... _fields_ = ("x", c_int), ("y", c_int)
... >>> class RECT(Structure):
... _fields_ = ("a", POINT), ("b", POINT)
... >>> p1 = POINT(1, 2)
>>> p2 = POINT(3, 4)
>>> rc = RECT(p1, p2)
>>> print(rc.a.x, rc.a.y, rc.b.x, rc.b.y)
... | trusted_official_docs | CPython Docs | Consider the following example::
>>> from ctypes import *
>>> class POINT(Structure):
... _fields_ = ("x", c_int), ("y", c_int)
... >>> class RECT(Structure):
... _fields_ = ("a", POINT), ("b", POINT)
... >>> p1 = POINT(1, 2)
>>> p2 = POINT(3, 4)
>>> rc = RECT(p1, p2)
>>> print(rc.a.x, rc.a.y, rc.b.x, rc.b.y)
... | Consider the following example::
>>> from ctypes import *
>>> class POINT(Structure):
... _fields_ = ("x", c_int), ("y", c_int)
... >>> class RECT(Structure):
... _fields_ = ("a", POINT), ("b", POINT)
... >>> p1 = POINT(1, 2)
>>> p2 = POINT(3, 4)
>>> rc = RECT(p1, p2)
>>> print(rc.a.x, rc.a.y, rc.b.x, rc.b.y)
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5fc42139-8453-4ba2-9077-06b353b12b58 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,494 | supabase-export-v2 | f8304110cec363a8 | the function call, and after the function execution the Python error flag is checked. If the error flag is set, a Python exception is raised.
Thus, this is only useful to call Python C API functions directly. | trusted_official_docs | CPython Docs | the function call, and after the function execution the Python error flag is checked. If the error flag is set, a Python exception is raised.
Thus, this is only useful to call Python C API functions directly. | the function call, and after the function execution the Python error flag is checked. If the error flag is set, a Python exception is raised.
Thus, this is only useful to call Python C API functions directly. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
5fccdc0e-2a93-46d4-bc2d-eb87f2033b09 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,616 | supabase-export-v2 | dab335fc4b68fc8c | >>> MessageBox() >>> MessageBox(text="Spam, spam, spam") >>> MessageBox(flags=2, text="foo bar")
A second example demonstrates output parameters. The win32 ``GetWindowRect``
function retrieves the dimensions of a specified window by copying them into
``RECT`` structure that the caller has to supply. Here is the C decla... | trusted_official_docs | CPython Docs | >>> MessageBox() >>> MessageBox(text="Spam, spam, spam") >>> MessageBox(flags=2, text="foo bar")
A second example demonstrates output parameters. The win32 ``GetWindowRect``
function retrieves the dimensions of a specified window by copying them into
``RECT`` structure that the caller has to supply. Here is the C decla... | >>> MessageBox() >>> MessageBox(text="Spam, spam, spam") >>> MessageBox(flags=2, text="foo bar")
A second example demonstrates output parameters. The win32 ``GetWindowRect``
function retrieves the dimensions of a specified window by copying them into
``RECT`` structure that the caller has to supply. Here is the C decla... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
60b3e628-638b-4648-b64f-5acc74eec279 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,751 | supabase-export-v2 | b0be2a26318eb4db | .. class:: _SimpleCData
This non-public class is the base class of all fundamental ctypes data
types. It is mentioned here because it contains the common attributes of the
fundamental ctypes data types. :class:`_SimpleCData` is a subclass of
:class:`_CData`, so it inherits their methods and attributes. ctypes data
... | trusted_official_docs | CPython Docs | .. class:: _SimpleCData
This non-public class is the base class of all fundamental ctypes data
types. It is mentioned here because it contains the common attributes of the
fundamental ctypes data types. :class:`_SimpleCData` is a subclass of
:class:`_CData`, so it inherits their methods and attributes. ctypes data
... | .. class:: _SimpleCData
This non-public class is the base class of all fundamental ctypes data
types. It is mentioned here because it contains the common attributes of the
fundamental ctypes data types. :class:`_SimpleCData` is a subclass of
:class:`_CData`, so it inherits their methods and attributes. ctypes data
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
60d8e24d-24f2-4e08-98e4-92fa025da855 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,646 | supabase-export-v2 | 4291fb690128f63b | This function creates a mutable character buffer. The returned object is a ctypes array of :class:`c_char`.
If *size* is given (and not ``None``), it must be an :class:`int`. It specifies the size of the returned array. | trusted_official_docs | CPython Docs | This function creates a mutable character buffer. The returned object is a ctypes array of :class:`c_char`.
If *size* is given (and not ``None``), it must be an :class:`int`. It specifies the size of the returned array. | This function creates a mutable character buffer. The returned object is a ctypes array of :class:`c_char`.
If *size* is given (and not ``None``), it must be an :class:`int`. It specifies the size of the returned array. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
61c7533b-56d9-41f8-a499-31d68cab75ea | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,219 | supabase-export-v2 | 9350365c70c973af | doctest: +WINDOWS Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Procedure probably called with not enough arguments (4 bytes missing) >>>
>>> windll.msvcrt.printf(b"spam") # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Proce... | trusted_official_docs | CPython Docs | doctest: +WINDOWS Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Procedure probably called with not enough arguments (4 bytes missing) >>>
>>> windll.msvcrt.printf(b"spam") # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Proce... | doctest: +WINDOWS Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Procedure probably called with not enough arguments (4 bytes missing) >>>
>>> windll.msvcrt.printf(b"spam") # doctest: +WINDOWS
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Proce... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
61ebffbe-4f8e-41e0-8da8-11f6b40382df | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,519 | supabase-export-v2 | 17672e3b735dfeff | on a loaded library raises an auditing event ``ctypes.dlsym`` with arguments ``library`` (the library object) and ``name`` (the symbol's name as a string or integer).
.. audit-event:: ctypes.dlsym/handle handle,name ctypes.LibraryLoader | trusted_official_docs | CPython Docs | on a loaded library raises an auditing event ``ctypes.dlsym`` with arguments ``library`` (the library object) and ``name`` (the symbol's name as a string or integer).
.. audit-event:: ctypes.dlsym/handle handle,name ctypes.LibraryLoader | on a loaded library raises an auditing event ``ctypes.dlsym`` with arguments ``library`` (the library object) and ``name`` (the symbol's name as a string or integer).
.. audit-event:: ctypes.dlsym/handle handle,name ctypes.LibraryLoader | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
63c39510-42ac-4c61-ae42-08964c6f107a | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,727 | supabase-export-v2 | 4912113736eae36b | specifies an offset into the source buffer in bytes; the default is zero. If the source buffer is not large enough a :exc:`ValueError` is raised.
.. audit-event:: ctypes.cdata/buffer pointer,size,offset ctypes._CData.from_buffer_copy | trusted_official_docs | CPython Docs | specifies an offset into the source buffer in bytes; the default is zero. If the source buffer is not large enough a :exc:`ValueError` is raised.
.. audit-event:: ctypes.cdata/buffer pointer,size,offset ctypes._CData.from_buffer_copy | specifies an offset into the source buffer in bytes; the default is zero. If the source buffer is not large enough a :exc:`ValueError` is raised.
.. audit-event:: ctypes.cdata/buffer pointer,size,offset ctypes._CData.from_buffer_copy | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
651063e4-130e-4950-8604-1fcb023c0262 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,269 | supabase-export-v2 | 6a51bb75dbfd2d8b | Specifying a format protects against incompatible argument types (just as a prototype for a C function), and tries to convert the arguments to valid types::
>>> printf(b"%d %d %d", 1, 2, 3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ctypes.ArgumentError: argument 2: TypeError: 'int' objec... | trusted_official_docs | CPython Docs | Specifying a format protects against incompatible argument types (just as a prototype for a C function), and tries to convert the arguments to valid types::
>>> printf(b"%d %d %d", 1, 2, 3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ctypes.ArgumentError: argument 2: TypeError: 'int' objec... | Specifying a format protects against incompatible argument types (just as a prototype for a C function), and tries to convert the arguments to valid types::
>>> printf(b"%d %d %d", 1, 2, 3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ctypes.ArgumentError: argument 2: TypeError: 'int' objec... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6642ae84-2678-4a9b-bb33-f4942aa4125b | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,518 | supabase-export-v2 | 47a3863c3f9bd006 | .. audit-event:: ctypes.dlsym library,name ctypes.LibraryLoader
Accessing a function on a loaded library raises an auditing event
``ctypes.dlsym`` with arguments ``library`` (the library object) and ``name``
(the symbol's name as a string or integer). | trusted_official_docs | CPython Docs | .. audit-event:: ctypes.dlsym library,name ctypes.LibraryLoader
Accessing a function on a loaded library raises an auditing event
``ctypes.dlsym`` with arguments ``library`` (the library object) and ``name``
(the symbol's name as a string or integer). | .. audit-event:: ctypes.dlsym library,name ctypes.LibraryLoader
Accessing a function on a loaded library raises an auditing event
``ctypes.dlsym`` with arguments ``library`` (the library object) and ``name``
(the symbol's name as a string or integer). | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
671d61a8-eeed-4346-9a0e-959eaa22a662 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,734 | supabase-export-v2 | 2e3d9dc1b8063317 | when the type is present in the foreign function's :attr:`~_CFuncPtr.argtypes` tuple; it must return an object that can be used as a function call parameter.
All ctypes data types have a default implementation of this classmethod
that normally returns *obj* if that is an instance of the type. Some
types accept other ... | trusted_official_docs | CPython Docs | when the type is present in the foreign function's :attr:`~_CFuncPtr.argtypes` tuple; it must return an object that can be used as a function call parameter.
All ctypes data types have a default implementation of this classmethod
that normally returns *obj* if that is an instance of the type. Some
types accept other ... | when the type is present in the foreign function's :attr:`~_CFuncPtr.argtypes` tuple; it must return an object that can be used as a function call parameter.
All ctypes data types have a default implementation of this classmethod
that normally returns *obj* if that is an instance of the type. Some
types accept other ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
673fbd93-eb95-4a37-9228-a3536e4452be | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,755 | supabase-export-v2 | 624b56023ca501f2 | integer, for character types, it is a single character bytes object or string, for character pointer types it is a Python bytes object or string.
When the ``value`` attribute is retrieved from a ctypes instance, usually
a new object is returned each time. :mod:`!ctypes` does *not* implement
original object return, al... | trusted_official_docs | CPython Docs | integer, for character types, it is a single character bytes object or string, for character pointer types it is a Python bytes object or string.
When the ``value`` attribute is retrieved from a ctypes instance, usually
a new object is returned each time. :mod:`!ctypes` does *not* implement
original object return, al... | integer, for character types, it is a single character bytes object or string, for character pointer types it is a Python bytes object or string.
When the ``value`` attribute is retrieved from a ctypes instance, usually
a new object is returned each time. :mod:`!ctypes` does *not* implement
original object return, al... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6826dada-6aff-4b33-ac07-85330a6c7d36 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,501 | supabase-export-v2 | 6140a1af32300a4b | The default mode which is used to load shared libraries. On OSX 10.3, this is *RTLD_GLOBAL*, otherwise it is the same as *RTLD_LOCAL*.
Shared libraries can also be loaded by using one of the prefabricated objects,
which are instances of the :class:`LibraryLoader` class, either by calling the
:meth:`~LibraryLoader.LoadL... | trusted_official_docs | CPython Docs | The default mode which is used to load shared libraries. On OSX 10.3, this is *RTLD_GLOBAL*, otherwise it is the same as *RTLD_LOCAL*.
Shared libraries can also be loaded by using one of the prefabricated objects,
which are instances of the :class:`LibraryLoader` class, either by calling the
:meth:`~LibraryLoader.LoadL... | The default mode which is used to load shared libraries. On OSX 10.3, this is *RTLD_GLOBAL*, otherwise it is the same as *RTLD_LOCAL*.
Shared libraries can also be loaded by using one of the prefabricated objects,
which are instances of the :class:`LibraryLoader` class, either by calling the
:meth:`~LibraryLoader.LoadL... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
683f566c-c94f-4d1a-82d9-40443d76dd09 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,720 | supabase-export-v2 | 1682a12017efc081 | .. class:: _CData
This non-public class is the common base class of all ctypes data types. Among other things, all ctypes type instances contain a memory block that
hold C compatible data; the address of the memory block is returned by the
:func:`addressof` helper function. Another instance variable is exposed as
:a... | trusted_official_docs | CPython Docs | .. class:: _CData
This non-public class is the common base class of all ctypes data types. Among other things, all ctypes type instances contain a memory block that
hold C compatible data; the address of the memory block is returned by the
:func:`addressof` helper function. Another instance variable is exposed as
:a... | .. class:: _CData
This non-public class is the common base class of all ctypes data types. Among other things, all ctypes type instances contain a memory block that
hold C compatible data; the address of the memory block is returned by the
:func:`addressof` helper function. Another instance variable is exposed as
:a... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
684a584f-a1b0-4ab1-9d05-5b794e12ff4f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,444 | supabase-export-v2 | 481610082209822f | 8 >>> resize(short_array, 4) Traceback (most recent call last): ... ValueError: minimum size is 8 >>> resize(short_array, 32) >>> sizeof(short_array) 32 >>> sizeof(type(short_array)) 8 >>>
This is nice and fine, but how would one access the additional elements
contained in this array? Since the type still only knows ab... | trusted_official_docs | CPython Docs | 8 >>> resize(short_array, 4) Traceback (most recent call last): ... ValueError: minimum size is 8 >>> resize(short_array, 32) >>> sizeof(short_array) 32 >>> sizeof(type(short_array)) 8 >>>
This is nice and fine, but how would one access the additional elements
contained in this array? Since the type still only knows ab... | 8 >>> resize(short_array, 4) Traceback (most recent call last): ... ValueError: minimum size is 8 >>> resize(short_array, 32) >>> sizeof(short_array) 32 >>> sizeof(type(short_array)) 8 >>>
This is nice and fine, but how would one access the additional elements
contained in this array? Since the type still only knows ab... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
686c1f5e-c4e0-489b-a6c0-4d12cefcb6ec | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,941 | supabase-export-v2 | 8a57fd5fb8a70e68 | Concrete pointer types are created by calling :func:`POINTER` with the type that will be pointed to; this is done automatically by :func:`pointer`.
If a pointer points to an array, its elements can be read and
written using standard subscript and slice accesses. Pointer objects
have no size, so :func:`len` will raise... | trusted_official_docs | CPython Docs | Concrete pointer types are created by calling :func:`POINTER` with the type that will be pointed to; this is done automatically by :func:`pointer`.
If a pointer points to an array, its elements can be read and
written using standard subscript and slice accesses. Pointer objects
have no size, so :func:`len` will raise... | Concrete pointer types are created by calling :func:`POINTER` with the type that will be pointed to; this is done automatically by :func:`pointer`.
If a pointer points to an array, its elements can be read and
written using standard subscript and slice accesses. Pointer objects
have no size, so :func:`len` will raise... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
693108d5-76e7-403e-a355-0a5fa0016872 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,192 | supabase-export-v2 | c089f69d6c38e6f9 | 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::
>>> from ctypes import *
>>> print(windll.kernel32) # doctest: +WINDOWS
<WinDLL 'kernel32', handle ... at ...>
>>> print(cdll.msvcrt) # doctest: +WINDOWS
... | trusted_official_docs | CPython Docs | 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::
>>> from ctypes import *
>>> print(windll.kernel32) # doctest: +WINDOWS
<WinDLL 'kernel32', handle ... at ...>
>>> print(cdll.msvcrt) # doctest: +WINDOWS
... | 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::
>>> from ctypes import *
>>> print(windll.kernel32) # doctest: +WINDOWS
<WinDLL 'kernel32', handle ... at ...>
>>> print(cdll.msvcrt) # doctest: +WINDOWS
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6a88466e-e5e7-419a-b2f3-4d95f771afa3 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,410 | supabase-export-v2 | 6ec89428790175d1 | they are used from C code. :mod:`!ctypes` doesn't, and if you don't, they may be garbage collected, crashing your program when a callback is made.
Also, note that if the callback function is called in a thread created
outside of Python's control (e.g. by the foreign code that calls the
callback), ctypes creates a new... | trusted_official_docs | CPython Docs | they are used from C code. :mod:`!ctypes` doesn't, and if you don't, they may be garbage collected, crashing your program when a callback is made.
Also, note that if the callback function is called in a thread created
outside of Python's control (e.g. by the foreign code that calls the
callback), ctypes creates a new... | they are used from C code. :mod:`!ctypes` doesn't, and if you don't, they may be garbage collected, crashing your program when a callback is made.
Also, note that if the callback function is called in a thread created
outside of Python's control (e.g. by the foreign code that calls the
callback), ctypes creates a new... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6ae14cab-9887-4e6c-9898-6864d5200122 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,553 | supabase-export-v2 | 447dff33996eb03e | Foreign functions ^^^^^^^^^^^^^^^^^
As explained in the previous section, foreign functions can be accessed as
attributes of loaded shared libraries. The function objects created in this way
by default accept any number of arguments, accept any ctypes data instances as
arguments, and return the default result type spec... | trusted_official_docs | CPython Docs | Foreign functions ^^^^^^^^^^^^^^^^^
As explained in the previous section, foreign functions can be accessed as
attributes of loaded shared libraries. The function objects created in this way
by default accept any number of arguments, accept any ctypes data instances as
arguments, and return the default result type spec... | Foreign functions ^^^^^^^^^^^^^^^^^
As explained in the previous section, foreign functions can be accessed as
attributes of loaded shared libraries. The function objects created in this way
by default accept any number of arguments, accept any ctypes data instances as
arguments, and return the default result type spec... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6b6d22f7-8e70-4754-b98d-e703842568ee | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,365 | supabase-export-v2 | 76e9033210a46a95 | Bar() >>> bar.values = (c_int * 3)(1, 2, 3) >>> bar.count = 3 >>> for i in range(bar.count): ... print(bar.values[i]) ... 1 2 3 >>>
In addition, if a function argument is explicitly declared to be a pointer type
(such as ``POINTER(c_int)``) in :attr:`~_CFuncPtr.argtypes`, an object of the pointed
type (``c_int`` in thi... | trusted_official_docs | CPython Docs | Bar() >>> bar.values = (c_int * 3)(1, 2, 3) >>> bar.count = 3 >>> for i in range(bar.count): ... print(bar.values[i]) ... 1 2 3 >>>
In addition, if a function argument is explicitly declared to be a pointer type
(such as ``POINTER(c_int)``) in :attr:`~_CFuncPtr.argtypes`, an object of the pointed
type (``c_int`` in thi... | Bar() >>> bar.values = (c_int * 3)(1, 2, 3) >>> bar.count = 3 >>> for i in range(bar.count): ... print(bar.values[i]) ... 1 2 3 >>>
In addition, if a function argument is explicitly declared to be a pointer type
(such as ``POINTER(c_int)``) in :attr:`~_CFuncPtr.argtypes`, an object of the pointed
type (``c_int`` in thi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6dd15f33-c4ba-4898-8a8b-16c8f6f5f828 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,394 | supabase-export-v2 | 75bf8966db6dc6de | :c:func:`!qsort` function, that is used to sort items with the help of a callback function. :c:func:`!qsort` will be used to sort an array of integers::
>>> IntArray5 = c_int * 5
>>> ia = IntArray5(5, 1, 7, 33, 99)
>>> qsort = libc.qsort
>>> qsort.restype = None
>>> | trusted_official_docs | CPython Docs | :c:func:`!qsort` function, that is used to sort items with the help of a callback function. :c:func:`!qsort` will be used to sort an array of integers::
>>> IntArray5 = c_int * 5
>>> ia = IntArray5(5, 1, 7, 33, 99)
>>> qsort = libc.qsort
>>> qsort.restype = None
>>> | :c:func:`!qsort` function, that is used to sort items with the help of a callback function. :c:func:`!qsort` will be used to sort an array of integers::
>>> IntArray5 = c_int * 5
>>> ia = IntArray5(5, 1, 7, 33, 99)
>>> qsort = libc.qsort
>>> qsort.restype = None
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6e326443-2f6a-4e27-a809-cd040ba999ea | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,303 | supabase-export-v2 | 66ff3c486ab8966b | Here is a RECT structure which contains two POINTs named *upperleft* and *lowerright*::
>>> class 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
>>> | trusted_official_docs | CPython Docs | Here is a RECT structure which contains two POINTs named *upperleft* and *lowerright*::
>>> class 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
>>> | Here is a RECT structure which contains two POINTs named *upperleft* and *lowerright*::
>>> class 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
>>> | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
6f7b407b-e419-486b-a424-2edb2f184684 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,866 | supabase-export-v2 | 23ccbf0d7931eadd | The :attr:`!_fields_` class variable can only be set once. Later assignments will raise an :exc:`AttributeError`.
Additionally, the :attr:`!_fields_` class variable must be defined before
the structure or union type is first used: an instance or subclass is
created, :func:`sizeof` is called on it, and so on. Later as... | trusted_official_docs | CPython Docs | The :attr:`!_fields_` class variable can only be set once. Later assignments will raise an :exc:`AttributeError`.
Additionally, the :attr:`!_fields_` class variable must be defined before
the structure or union type is first used: an instance or subclass is
created, :func:`sizeof` is called on it, and so on. Later as... | The :attr:`!_fields_` class variable can only be set once. Later assignments will raise an :exc:`AttributeError`.
Additionally, the :attr:`!_fields_` class variable must be defined before
the structure or union type is first used: an instance or subclass is
created, :func:`sizeof` is called on it, and so on. Later as... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
703f1f3b-16ce-43cd-8284-f0d0e3d73ba2 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,476 | supabase-export-v2 | 6df329ea2652f54c | therefore accessing it repeatedly returns the same object each time. On the other hand, accessing it through an index returns a new object each time::
>>> from ctypes import CDLL
>>> libc = CDLL("libc.so.6") # On Linux
>>> libc.time == libc.time
True
>>> libc['time'] == libc['time']
False | trusted_official_docs | CPython Docs | therefore accessing it repeatedly returns the same object each time. On the other hand, accessing it through an index returns a new object each time::
>>> from ctypes import CDLL
>>> libc = CDLL("libc.so.6") # On Linux
>>> libc.time == libc.time
True
>>> libc['time'] == libc['time']
False | therefore accessing it repeatedly returns the same object each time. On the other hand, accessing it through an index returns a new object each time::
>>> from ctypes import CDLL
>>> libc = CDLL("libc.so.6") # On Linux
>>> libc.time == libc.time
True
>>> libc['time'] == libc['time']
False | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
708f65ed-5f7c-437a-ad9f-54c7895a5908 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,584 | supabase-export-v2 | b5601024061199b0 | the system :data:`errno` variable is exchanged with the real :data:`errno` value before and after the call; *use_last_error* does the same for the Windows error code.
.. function:: WINFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False) | trusted_official_docs | CPython Docs | the system :data:`errno` variable is exchanged with the real :data:`errno` value before and after the call; *use_last_error* does the same for the Windows error code.
.. function:: WINFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False) | the system :data:`errno` variable is exchanged with the real :data:`errno` value before and after the call; *use_last_error* does the same for the Windows error code.
.. function:: WINFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False) | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
70e3e889-b79a-426f-9abe-34d2843ff3ef | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,468 | supabase-export-v2 | 58f93830c98a20e9 | the :func:`GetLastError` and :func:`!SetLastError` Windows API functions; :func:`ctypes.get_last_error` and :func:`ctypes.set_last_error` are used to request and change the ctypes private copy of the windows error code.
The *winmode* parameter is used on Windows to specify how the library is loaded
(since *mode* is ig... | trusted_official_docs | CPython Docs | the :func:`GetLastError` and :func:`!SetLastError` Windows API functions; :func:`ctypes.get_last_error` and :func:`ctypes.set_last_error` are used to request and change the ctypes private copy of the windows error code.
The *winmode* parameter is used on Windows to specify how the library is loaded
(since *mode* is ig... | the :func:`GetLastError` and :func:`!SetLastError` Windows API functions; :func:`ctypes.get_last_error` and :func:`ctypes.set_last_error` are used to request and change the ctypes private copy of the windows error code.
The *winmode* parameter is used on Windows to specify how the library is loaded
(since *mode* is ig... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
715396a4-8786-4add-954d-6742d0ba4cc5 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,764 | supabase-export-v2 | a9787c4693758886 | .. XXX above is false, it actually returns a Unicode string
Subclasses of fundamental data types do *not* inherit this behavior. So, if a
foreign functions :attr:`!restype` is a subclass of :class:`c_void_p`, you will
receive an instance of this subclass from the function call. Of course, you can
get the value of the p... | trusted_official_docs | CPython Docs | .. XXX above is false, it actually returns a Unicode string
Subclasses of fundamental data types do *not* inherit this behavior. So, if a
foreign functions :attr:`!restype` is a subclass of :class:`c_void_p`, you will
receive an instance of this subclass from the function call. Of course, you can
get the value of the p... | .. XXX above is false, it actually returns a Unicode string
Subclasses of fundamental data types do *not* inherit this behavior. So, if a
foreign functions :attr:`!restype` is a subclass of :class:`c_void_p`, you will
receive an instance of this subclass from the function call. Of course, you can
get the value of the p... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
718b8fa7-1e15-40ba-bc98-1b9144977eb8 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,430 | supabase-export-v2 | 1fa6e6a1e9555b4d | 3 4 >>> # now swap the two points >>> rc.a, rc.b = rc.b, rc.a >>> print(rc.a.x, rc.a.y, rc.b.x, rc.b.y) 3 4 3 4 >>>
Hm. We certainly expected the last statement to print ``3 4 1 2``. What
happened? Here are the steps of the ``rc.a, rc.b = rc.b, rc.a`` line above:: | trusted_official_docs | CPython Docs | 3 4 >>> # now swap the two points >>> rc.a, rc.b = rc.b, rc.a >>> print(rc.a.x, rc.a.y, rc.b.x, rc.b.y) 3 4 3 4 >>>
Hm. We certainly expected the last statement to print ``3 4 1 2``. What
happened? Here are the steps of the ``rc.a, rc.b = rc.b, rc.a`` line above:: | 3 4 >>> # now swap the two points >>> rc.a, rc.b = rc.b, rc.a >>> print(rc.a.x, rc.a.y, rc.b.x, rc.b.y) 3 4 3 4 >>>
Hm. We certainly expected the last statement to print ``3 4 1 2``. What
happened? Here are the steps of the ``rc.a, rc.b = rc.b, rc.a`` line above:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7204e257-3312-43d3-be9f-890eeed9d275 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,874 | supabase-export-v2 | 4dd3dc7f210e8656 | .. deprecated-removed:: 3.14 3.19
For historical reasons, if :attr:`!_pack_` is non-zero,
the MSVC-compatible layout will be used by default. On non-Windows platforms, this default is deprecated and is slated to
become an error in Python 3.19. If it is intended, set :attr:`~Structure._layout_` to ``'ms'``
explicitly... | trusted_official_docs | CPython Docs | .. deprecated-removed:: 3.14 3.19
For historical reasons, if :attr:`!_pack_` is non-zero,
the MSVC-compatible layout will be used by default. On non-Windows platforms, this default is deprecated and is slated to
become an error in Python 3.19. If it is intended, set :attr:`~Structure._layout_` to ``'ms'``
explicitly... | .. deprecated-removed:: 3.14 3.19
For historical reasons, if :attr:`!_pack_` is non-zero,
the MSVC-compatible layout will be used by default. On non-Windows platforms, this default is deprecated and is slated to
become an error in Python 3.19. If it is intended, set :attr:`~Structure._layout_` to ``'ms'``
explicitly... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7216e02a-ac60-4736-9424-29d4f32dd557 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,466 | supabase-export-v2 | 89a9cc9eb7b6b107 | with ``use_errno=True`` then the :data:`errno` value before the function call is swapped with the ctypes private copy, the same happens immediately after the function call.
The function :func:`ctypes.get_errno` returns the value of the ctypes private
copy, and the function :func:`ctypes.set_errno` changes the ctypes p... | trusted_official_docs | CPython Docs | with ``use_errno=True`` then the :data:`errno` value before the function call is swapped with the ctypes private copy, the same happens immediately after the function call.
The function :func:`ctypes.get_errno` returns the value of the ctypes private
copy, and the function :func:`ctypes.set_errno` changes the ctypes p... | with ``use_errno=True`` then the :data:`errno` value before the function call is swapped with the ctypes private copy, the same happens immediately after the function call.
The function :func:`ctypes.get_errno` returns the value of the ctypes private
copy, and the function :func:`ctypes.set_errno` changes the ctypes p... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
72896306-758f-41b9-ba25-63da035da38f | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,832 | supabase-export-v2 | 9c0ffffa263245f5 | .. class:: c_bool
Represent the C :c:expr:`bool` datatype (more accurately, :c:expr:`_Bool` from
C99). Its value can be ``True`` or ``False``, and the constructor accepts any object
that has a truth value. | trusted_official_docs | CPython Docs | .. class:: c_bool
Represent the C :c:expr:`bool` datatype (more accurately, :c:expr:`_Bool` from
C99). Its value can be ``True`` or ``False``, and the constructor accepts any object
that has a truth value. | .. class:: c_bool
Represent the C :c:expr:`bool` datatype (more accurately, :c:expr:`_Bool` from
C99). Its value can be ``True`` or ``False``, and the constructor accepts any object
that has a truth value. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
72ce1de1-6f46-492e-8057-f2421657ed1e | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,713 | supabase-export-v2 | 04c25413f0033a24 | *void \*ptr*. If *size* is specified, it is used as the number of characters of the string, otherwise the string is assumed to be zero-terminated.
.. audit-event:: ctypes.wstring_at ptr,size ctypes.wstring_at | trusted_official_docs | CPython Docs | *void \*ptr*. If *size* is specified, it is used as the number of characters of the string, otherwise the string is assumed to be zero-terminated.
.. audit-event:: ctypes.wstring_at ptr,size ctypes.wstring_at | *void \*ptr*. If *size* is specified, it is used as the number of characters of the string, otherwise the string is assumed to be zero-terminated.
.. audit-event:: ctypes.wstring_at ptr,size ctypes.wstring_at | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
730e70e3-2420-4c9f-8df4-772383929b31 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,683 | supabase-export-v2 | f9519c41dabe4503 | .. function:: memmove(dst, src, count)
Same as the standard C 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. | trusted_official_docs | CPython Docs | .. function:: memmove(dst, src, count)
Same as the standard C 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:: memmove(dst, src, count)
Same as the standard C 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. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7414ae94-d9b3-40c6-9552-45e274726874 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,326 | supabase-export-v2 | 0e5fa5719f8351f6 | c_int), ("y", c_int) ... >>> class MyStruct(Structure): ... _fields_ = [("a", c_int), ... ("b", c_float), ... ("point_array", POINT * 4)] >>> >>> print(len(MyStruct().point_array)) 4 >>>
Instances are created in the usual way, by calling the class:: | trusted_official_docs | CPython Docs | c_int), ("y", c_int) ... >>> class MyStruct(Structure): ... _fields_ = [("a", c_int), ... ("b", c_float), ... ("point_array", POINT * 4)] >>> >>> print(len(MyStruct().point_array)) 4 >>>
Instances are created in the usual way, by calling the class:: | c_int), ("y", c_int) ... >>> class MyStruct(Structure): ... _fields_ = [("a", c_int), ... ("b", c_float), ... ("point_array", POINT * 4)] >>> >>> print(len(MyStruct().point_array)) 4 >>>
Instances are created in the usual way, by calling the class:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
774793e3-e7f6-49a6-9dd5-b0176a77ffd8 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,266 | supabase-export-v2 | a2cda4893e3491bb | It is possible to specify the required argument types of functions exported from DLLs by setting the :attr:`~_CFuncPtr.argtypes` attribute.
:attr:`~_CFuncPtr.argtypes` must be a sequence of C data types (the :func:`!printf` function is
probably not a good example here, because it takes a variable number and
different t... | trusted_official_docs | CPython Docs | It is possible to specify the required argument types of functions exported from DLLs by setting the :attr:`~_CFuncPtr.argtypes` attribute.
:attr:`~_CFuncPtr.argtypes` must be a sequence of C data types (the :func:`!printf` function is
probably not a good example here, because it takes a variable number and
different t... | It is possible to specify the required argument types of functions exported from DLLs by setting the :attr:`~_CFuncPtr.argtypes` attribute.
:attr:`~_CFuncPtr.argtypes` must be a sequence of C data types (the :func:`!printf` function is
probably not a good example here, because it takes a variable number and
different t... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
788d8f64-f690-42b7-82f1-45e41deca842 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,754 | supabase-export-v2 | b5215fc65ce5c6aa | .. attribute:: value
This attribute contains the actual value of the instance. For integer and
pointer types, it is an integer, for character types, it is a single
character bytes object or string, for character pointer types it is a
Python bytes object or string. | trusted_official_docs | CPython Docs | .. attribute:: value
This attribute contains the actual value of the instance. For integer and
pointer types, it is an integer, for character types, it is a single
character bytes object or string, for character pointer types it is a
Python bytes object or string. | .. attribute:: value
This attribute contains the actual value of the instance. For integer and
pointer types, it is an integer, for character types, it is a single
character bytes object or string, for character pointer types it is a
Python bytes object or string. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
78dbc104-1958-499a-b2de-8cd3f62ed73d | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,425 | supabase-export-v2 | a6b9d388892393d6 | >>> 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 12345 >>>
The fact that standard Python has a frozen module and a frozen package
(indicated by the negative ``size`` member) is not well known... | trusted_official_docs | CPython Docs | >>> 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 12345 >>>
The fact that standard Python has a frozen module and a frozen package
(indicated by the negative ``size`` member) is not well known... | >>> 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 12345 >>>
The fact that standard Python has a frozen module and a frozen package
(indicated by the negative ``size`` member) is not well known... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
79c95dce-58a3-46f0-904e-cce368c4f47d | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,717 | supabase-export-v2 | f6961c823926ab40 | returned :class:`!memoryview` object can not be used to modify the underlying memory. (Changes made by other means will still be reflected in the returned object.)
This function is similar to :func:`string_at` with the key
difference of not making a copy of the specified memory. It is a semantically equivalent (but mo... | trusted_official_docs | CPython Docs | returned :class:`!memoryview` object can not be used to modify the underlying memory. (Changes made by other means will still be reflected in the returned object.)
This function is similar to :func:`string_at` with the key
difference of not making a copy of the specified memory. It is a semantically equivalent (but mo... | returned :class:`!memoryview` object can not be used to modify the underlying memory. (Changes made by other means will still be reflected in the returned object.)
This function is similar to :func:`string_at` with the key
difference of not making a copy of the specified memory. It is a semantically equivalent (but mo... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
79f6242d-1849-492e-8678-2dac3c449a1c | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,224 | supabase-export-v2 | f79fa785ee60ae73 | so you should be careful anyway. The :mod:`faulthandler` module can be helpful in debugging crashes (e.g. from segmentation faults produced by erroneous C library calls).
``None``, integers, bytes objects and (unicode) strings are the only native
Python objects that can directly be used as parameters in these function ... | trusted_official_docs | CPython Docs | so you should be careful anyway. The :mod:`faulthandler` module can be helpful in debugging crashes (e.g. from segmentation faults produced by erroneous C library calls).
``None``, integers, bytes objects and (unicode) strings are the only native
Python objects that can directly be used as parameters in these function ... | so you should be careful anyway. The :mod:`faulthandler` module can be helpful in debugging crashes (e.g. from segmentation faults produced by erroneous C library calls).
``None``, integers, bytes objects and (unicode) strings are the only native
Python objects that can directly be used as parameters in these function ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
79ff0512-9745-4cf8-98e1-1e2e1aefe806 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,520 | supabase-export-v2 | 39db511a70650d7c | .. audit-event:: ctypes.dlsym/handle handle,name ctypes.LibraryLoader
In cases when only the library handle is available rather than the object,
accessing a function raises an auditing event ``ctypes.dlsym/handle`` with
arguments ``handle`` (the raw library handle) and ``name``. | trusted_official_docs | CPython Docs | .. audit-event:: ctypes.dlsym/handle handle,name ctypes.LibraryLoader
In cases when only the library handle is available rather than the object,
accessing a function raises an auditing event ``ctypes.dlsym/handle`` with
arguments ``handle`` (the raw library handle) and ``name``. | .. audit-event:: ctypes.dlsym/handle handle,name ctypes.LibraryLoader
In cases when only the library handle is available rather than the object,
accessing a function raises an auditing event ``ctypes.dlsym/handle`` with
arguments ``handle`` (the raw library handle) and ``name``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7b21432d-c2e6-414f-9303-5305802afdcc | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,590 | supabase-export-v2 | 950f9f4aedb4c89f | 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:
.. function:: prototype(address)
:noindex:
:module: | trusted_official_docs | CPython Docs | 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:
.. function:: prototype(address)
:noindex:
:module: | 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:
.. function:: prototype(address)
:noindex:
:module: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7b368b6f-9f19-4491-88b1-1b1234caac1b | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,560 | supabase-export-v2 | cf7ffbda3d055845 | Instances of foreign functions are also C compatible data types; they represent C function pointers.
This behavior can be customized by assigning to special attributes of the
foreign function object. | trusted_official_docs | CPython Docs | Instances of foreign functions are also C compatible data types; they represent C function pointers.
This behavior can be customized by assigning to special attributes of the
foreign function object. | Instances of foreign functions are also C compatible data types; they represent C function pointers.
This behavior can be customized by assigning to special attributes of the
foreign function object. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7bf901f5-f259-4906-bcbb-07d5e36f2cbb | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,929 | supabase-export-v2 | 75bad1dfb45d6a55 | Abstract base class for arrays.
The recommended way to create concrete array types is by multiplying any
:mod:`!ctypes` data type with a non-negative integer. Alternatively, you can subclass
this type and define :attr:`_length_` and :attr:`_type_` class variables. Array elements can be read and written using standard... | trusted_official_docs | CPython Docs | Abstract base class for arrays.
The recommended way to create concrete array types is by multiplying any
:mod:`!ctypes` data type with a non-negative integer. Alternatively, you can subclass
this type and define :attr:`_length_` and :attr:`_type_` class variables. Array elements can be read and written using standard... | Abstract base class for arrays.
The recommended way to create concrete array types is by multiplying any
:mod:`!ctypes` data type with a non-negative integer. Alternatively, you can subclass
this type and define :attr:`_length_` and :attr:`_type_` class variables. Array elements can be read and written using standard... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7cda870b-989e-4d02-a791-e879d794217e | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,578 | supabase-export-v2 | 065bde85ebfd8ab5 | .. audit-event:: ctypes.call_function func_pointer,arguments foreign-functions
Some ways to invoke foreign function calls as well as some of the
functions in this module may raise an auditing event
``ctypes.call_function`` with arguments ``function pointer`` and ``arguments``. | trusted_official_docs | CPython Docs | .. audit-event:: ctypes.call_function func_pointer,arguments foreign-functions
Some ways to invoke foreign function calls as well as some of the
functions in this module may raise an auditing event
``ctypes.call_function`` with arguments ``function pointer`` and ``arguments``. | .. audit-event:: ctypes.call_function func_pointer,arguments foreign-functions
Some ways to invoke foreign function calls as well as some of the
functions in this module may raise an auditing event
``ctypes.call_function`` with arguments ``function pointer`` and ``arguments``. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7cff8d45-6e88-4fea-85aa-c9d43b47b529 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,839 | supabase-export-v2 | 1d164d21c0e4c974 | .. _ctypes-wintypes:
The :mod:`!ctypes.wintypes` module provides quite some other Windows specific
data types, for example :c:type:`!HWND`, :c:type:`!WPARAM`,
:c:type:`!VARIANT_BOOL` or :c:type:`!DWORD`. Some useful structures like :c:type:`!MSG` or :c:type:`!RECT` are also defined. | trusted_official_docs | CPython Docs | .. _ctypes-wintypes:
The :mod:`!ctypes.wintypes` module provides quite some other Windows specific
data types, for example :c:type:`!HWND`, :c:type:`!WPARAM`,
:c:type:`!VARIANT_BOOL` or :c:type:`!DWORD`. Some useful structures like :c:type:`!MSG` or :c:type:`!RECT` are also defined. | .. _ctypes-wintypes:
The :mod:`!ctypes.wintypes` module provides quite some other Windows specific
data types, for example :c:type:`!HWND`, :c:type:`!WPARAM`,
:c:type:`!VARIANT_BOOL` or :c:type:`!DWORD`. Some useful structures like :c:type:`!MSG` or :c:type:`!RECT` are also defined. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7e4c0178-ec9e-46c4-b538-0e4b85295ce5 | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,318 | supabase-export-v2 | 9d9ef86c358fae1f | unions containing bit fields. Bit fields are only possible for integer fields, the bit width is specified as the third item in the :attr:`~Structure._fields_` tuples::
>>> class Int(Structure):
... _fields_ = [("first_16", c_int, 16),
... ("second_16", c_int, 16)]
... >>> print(Int.first_16)
<ctypes.CField 'first_1... | trusted_official_docs | CPython Docs | unions containing bit fields. Bit fields are only possible for integer fields, the bit width is specified as the third item in the :attr:`~Structure._fields_` tuples::
>>> class Int(Structure):
... _fields_ = [("first_16", c_int, 16),
... ("second_16", c_int, 16)]
... >>> print(Int.first_16)
<ctypes.CField 'first_1... | unions containing bit fields. Bit fields are only possible for integer fields, the bit width is specified as the third item in the :attr:`~Structure._fields_` tuples::
>>> class Int(Structure):
... _fields_ = [("first_16", c_int, 16),
... ("second_16", c_int, 16)]
... >>> print(Int.first_16)
<ctypes.CField 'first_1... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
7edabbce-6c9b-4825-ab67-ff39a0b415ff | CPython Docs | file://datasets/cpython/Doc/library/ctypes.rst | unknown | e6da9521-72d3-4c05-ab3f-df7c68f7662d | 39,452 | supabase-export-v2 | 9997ccc58ed280dd | There are several ways to load shared libraries into the Python process. One way is to instantiate :py:class:`CDLL` or one of its subclasses:
.. class:: CDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=None) | trusted_official_docs | CPython Docs | There are several ways to load shared libraries into the Python process. One way is to instantiate :py:class:`CDLL` or one of its subclasses:
.. class:: CDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=None) | There are several ways to load shared libraries into the Python process. One way is to instantiate :py:class:`CDLL` or one of its subclasses:
.. class:: CDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=None) | 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.