A node visitor base class that walks the abstract syntax tree and calls a
visitor function for every node found. This function may return a value
- which is forwarded by the `visit` method.
+ which is forwarded by the :meth:`visit` method.
This class is meant to be subclassed, with the subclass adding visitor
methods.
A :class:`NodeVisitor` subclass that walks the abstract syntax tree and
allows modification of nodes.
- The `NodeTransformer` will walk the AST and use the return value of the
- visitor methods to replace or remove the old node. If the return value of
- the visitor method is ``None``, the node will be removed from its location,
- otherwise it is replaced with the return value. The return value may be the
- original node in which case no replacement takes place.
+ The :class:`NodeTransformer` will walk the AST and use the return value of
+ the visitor methods to replace or remove the old node. If the return value
+ of the visitor method is ``None``, the node will be removed from its
+ location, otherwise it is replaced with the return value. The return value
+ may be the original node in which case no replacement takes place.
Here is an example transformer that rewrites all occurrences of name lookups
(``foo``) to ``data['foo']``::
The *mode* parameter can be used to specify how the library is loaded. For
details, consult the ``dlopen(3)`` manpage, on Windows, *mode* is ignored.
-The *use_errno* parameter, when set to True, enables a ctypes
-mechanism that allows to access the system `errno` error number in a
-safe way. `ctypes` maintains a thread-local copy of the systems
-`errno` variable; if you call foreign functions created with
-`use_errno=True` then the `errno` value before the function call is
-swapped with the ctypes private copy, the same happens immediately
-after the function call.
-
-The function `ctypes.get_errno()` returns the value of the ctypes
-private copy, and the function `ctypes.set_errno(value)` changes the
-ctypes private copy to `value` and returns the former value.
-
-The *use_last_error* parameter, when set to True, enables the same
-mechanism for the Windows error code which is managed by the
-:func:`GetLastError` and :func:`SetLastError` Windows API functions;
-`ctypes.get_last_error()` and `ctypes.set_last_error(value)` are used
-to request and change the ctypes private copy of the windows error
-code.
+The *use_errno* parameter, when set to True, enables a ctypes mechanism that
+allows to access the system :data:`errno` error number in a safe way.
+:mod:`ctypes` maintains a thread-local copy of the systems :data:`errno`
+variable; if you call foreign functions created 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 private copy
+to a new value and returns the former value.
+
+The *use_last_error* parameter, when set to True, enables the same mechanism for
+the Windows error code which is managed by the :func:`GetLastError` and
+:func:`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.
.. data:: RTLD_GLOBAL
:noindex:
.. function:: CFUNCTYPE(restype, *argtypes, use_errno=False, use_last_error=False)
The returned function prototype creates functions that use the standard C
- calling convention. The function will release the GIL during the call.
- If `use_errno` is set to True, the ctypes private copy of the system `errno`
- variable is exchanged with the real `errno` value bafore and after the call;
- `use_last_error` does the same for the Windows error code.
+ calling convention. The function will release the GIL during the call. If
+ *use_errno* is set to True, the ctypes private copy of the system
+ :data:`errno` variable is exchanged with the real :data:`errno` value bafore
+ 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)
Windows only: The returned function prototype creates functions that use the
- ``stdcall`` calling convention, except on Windows CE where :func:`WINFUNCTYPE`
- is the same as :func:`CFUNCTYPE`. The function will release the GIL during the
- call. `use_errno` and `use_last_error` have the same meaning as above.
+ ``stdcall`` calling convention, except on Windows CE where
+ :func:`WINFUNCTYPE` is the same as :func:`CFUNCTYPE`. The function will
+ release the GIL during the call. *use_errno* and *use_last_error* have the
+ same meaning as above.
.. function:: PYFUNCTYPE(restype, *argtypes)
.. function:: find_library(name)
:module: ctypes.util
- Try to find a library and return a pathname. `name` is the library name without
- any prefix like `lib`, suffix like ``.so``, ``.dylib`` or version number (this
- is the form used for the posix linker option :option:`-l`). If no library can
- be found, returns ``None``.
+ Try to find a library and return a pathname. *name* is the library name
+ without any prefix like ``lib```, suffix like ``.so``, ``.dylib`` or version
+ number (this is the form used for the posix linker option :option:`-l`). If
+ no library can be found, returns ``None``.
The exact functionality is system dependent.
.. function:: get_errno()
Returns the current value of the ctypes-private copy of the system
- `errno` variable in the calling thread.
+ :data:`errno` variable in the calling thread.
.. function:: get_last_error()
Windows only: returns the current value of the ctypes-private copy of the system
- `LastError` variable in the calling thread.
+ :data:`LastError` variable in the calling thread.
.. function:: memmove(dst, src, count)
.. function:: set_errno(value)
- Set the current value of the ctypes-private copy of the system
- `errno` variable in the calling thread to `value` and return the
- previous value.
+ Set the current value of the ctypes-private copy of the system :data:`errno`
+ variable in the calling thread to *value* and return the previous value.
.. function:: set_last_error(value)
- Windows only: set the current value of the ctypes-private copy of
- the system `LastError` variable in the calling thread to `value`
- and return the previous value.
+ Windows only: set the current value of the ctypes-private copy of the system
+ :data:`LastError` variable in the calling thread to *value* and return the
+ previous value.
.. function:: sizeof(obj_or_type)