mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
gh-107442: Document all valid types for ctypes _as_parameter_ (#107443)
This commit is contained in:
parent
a6675b1a59
commit
6925c578a0
1 changed files with 4 additions and 3 deletions
|
@ -401,9 +401,10 @@ Calling functions with your own custom data types
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
You can also customize :mod:`ctypes` argument conversion to allow instances of
|
You can also customize :mod:`ctypes` argument conversion to allow instances of
|
||||||
your own classes be used as function arguments. :mod:`ctypes` looks for an
|
your own classes be used as function arguments. :mod:`ctypes` looks for an
|
||||||
:attr:`!_as_parameter_` attribute and uses this as the function argument. Of
|
:attr:`!_as_parameter_` attribute and uses this as the function argument. The
|
||||||
course, it must be one of integer, string, or bytes::
|
attribute must be an integer, string, bytes, a :mod:`ctypes` instance, or an
|
||||||
|
object with an :attr:`!_as_parameter_` attribute::
|
||||||
|
|
||||||
>>> class Bottles:
|
>>> class Bottles:
|
||||||
... def __init__(self, number):
|
... def __init__(self, number):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue