Deleted Added
sdiff udiff text old ( 11986:c12e4625ab56 ) new ( 12037:d28054ac6ec9 )
full compact
1Python types
2############
3
4Available wrappers
5==================
6
7All major Python types are available as thin C++ wrapper classes. These
8can also be used as function parameters -- see :ref:`python_objects_as_args`.

--- 19 unchanged lines hidden (view full) ---

28
29.. code-block:: cpp
30
31 py::object obj = ...;
32 MyClass *cls = obj.cast<MyClass *>();
33
34When conversion fails, both directions throw the exception :class:`cast_error`.
35
36Calling Python functions
37========================
38
39It is also possible to call python functions via ``operator()``.
40
41.. code-block:: cpp
42
43 py::function f = <...>;

--- 8 unchanged lines hidden (view full) ---

52 ... # function code
53
54 f(1234, say="hello", to=some_instance) # keyword call in Python
55
56In C++, the same call can be made using:
57
58.. code-block:: cpp
59
60 using pybind11::literals; // to bring in the `_a` literal
61 f(1234, "say"_a="hello", "to"_a=some_instance); // keyword call in C++
62
63Unpacking of ``*args`` and ``**kwargs`` is also possible and can be mixed with
64other arguments:
65
66.. code-block:: cpp
67
68 // * unpacking

--- 28 unchanged lines hidden ---