Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
99279f71
Commit
99279f71
authored
Jun 03, 2016
by
Wenzel Jakob
Browse files
docs: switched lexer for python console snippets to 'pycon'
parent
7c99ff2a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
17 deletions
+17
-17
docs/advanced.rst
docs/advanced.rst
+6
-6
docs/basics.rst
docs/basics.rst
+4
-4
docs/classes.rst
docs/classes.rst
+7
-7
No files found.
docs/advanced.rst
View file @
99279f71
...
...
@@ -157,7 +157,7 @@ trivial to generate binding code for both of these functions.
The following interactive session shows how to call them from Python.
.. code-block:: py
th
on
.. code-block:: py
c
on
$ python
>>> import example
...
...
@@ -304,7 +304,7 @@ by pybind11. Following this, we are able to define a constructor as usual.
The Python session below shows how to override ``Animal::go`` and invoke it via
a virtual method call.
.. code-block:: py
th
on
.. code-block:: py
c
on
>>> from example import *
>>> d = Dog()
...
...
@@ -834,7 +834,7 @@ Suppose we bind the following function
and call it from Python, the following happens:
.. code-block:: py
th
on
.. code-block:: py
c
on
>>> v = [5, 6]
>>> append_1(v)
...
...
@@ -863,7 +863,7 @@ functions:
In this case, properties can be read and written in their entirety. However, an
``append`` operaton involving such a list type has no effect:
.. code-block:: py
th
on
.. code-block:: py
c
on
>>> m = MyClass()
>>> m.contents = [5, 6]
...
...
@@ -1144,7 +1144,7 @@ entirely on the C++ side and can be crunched down into a tight, optimized loop
by the compiler. The result is returned as a NumPy array of type
``numpy.dtype.float64``.
.. code-block:: py
th
on
.. code-block:: py
c
on
>>> x = np.array([[1, 3],[5, 7]])
>>> y = np.array([[2, 4],[6, 8]])
...
...
@@ -1316,7 +1316,7 @@ Another aspect worth highlighting is that the "preview" of the default argument
in the function signature is generated using the object's ``__repr__`` method.
If not available, the signature may not be very helpful, e.g.:
.. code-block:: py
th
on
.. code-block:: py
c
on
FUNCTIONS
...
...
...
docs/basics.rst
View file @
99279f71
...
...
@@ -128,7 +128,7 @@ Assuming that the created file :file:`example.so` (:file:`example.pyd` on Window
is located in the current directory, the following interactive Python session
shows how to load and execute the example.
.. code-block:: py
th
on
.. code-block:: py
c
on
$ python
Python 2.7.10 (default, Aug 22 2015, 20:33:39)
...
...
@@ -157,7 +157,7 @@ metadata into :func:`module::def`. With this modified binding code, we can now
call the function using keyword arguments, which is a more readable alternative
particularly for functions taking many parameters:
.. code-block:: py
th
on
.. code-block:: py
c
on
>>> import example
>>> example.add(i=1, j=2)
...
...
@@ -165,7 +165,7 @@ particularly for functions taking many parameters:
The keyword names also appear in the function signatures within the documentation.
.. code-block:: py
th
on
.. code-block:: py
c
on
>>> help(example)
...
...
@@ -201,7 +201,7 @@ using an extension of :class:`arg`:
The default values also appear within the documentation.
.. code-block:: py
th
on
.. code-block:: py
c
on
>>> help(example)
...
...
docs/classes.rst
View file @
99279f71
...
...
@@ -44,7 +44,7 @@ constructor's parameters as template arguments and wraps the corresponding
constructor (see the :ref:`custom_constructors` section for details). An
interactive Python session demonstrating this example is shown below:
.. code-block:: py
th
on
.. code-block:: py
c
on
% python
>>> import example
...
...
@@ -73,7 +73,7 @@ Binding lambda functions
Note how ``print(p)`` produced a rather useless summary of our data structure in the example above:
.. code-block:: py
th
on
.. code-block:: py
c
on
>>> print(p)
<example.Pet object at 0x10cd98060>
...
...
@@ -99,7 +99,7 @@ Lambda function instead:
Both stateless [#f1]_ and stateful lambda closures are supported by pybind11.
With the above change, the same Python code now produces the following output:
.. code-block:: py
th
on
.. code-block:: py
c
on
>>> print(p)
<example.Pet named 'Molly'>
...
...
@@ -120,7 +120,7 @@ method also exists for ``const`` fields.
This makes it possible to write
.. code-block:: py
th
on
.. code-block:: py
c
on
>>> p = example.Pet('Molly')
>>> p.name
...
...
@@ -212,7 +212,7 @@ Alternatively, we can also assign a name to the previously bound ``Pet``
Functionality-wise, both approaches are completely equivalent. Afterwards,
instances will expose fields and methods of both types:
.. code-block:: py
th
on
.. code-block:: py
c
on
>>> p = example.Dog('Molly')
>>> p.name
...
...
@@ -253,7 +253,7 @@ sequence.
The overload signatures are also visible in the method's docstring:
.. code-block:: py
th
on
.. code-block:: py
c
on
>>> help(example.Pet)
...
...
@@ -319,7 +319,7 @@ constructor. The :func:`enum_::export_values` function exports the enum entries
into the parent scope, which should be skipped for newer C++11-style strongly
typed enums.
.. code-block:: py
th
on
.. code-block:: py
c
on
>>> p = Pet('Lucy', Pet.Cat)
>>> p.type
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment