docs: switched lexer for python console snippets to 'pycon'

This commit is contained in:
Wenzel Jakob 2016-06-03 11:19:29 +02:00
parent 7c99ff2a00
commit 99279f7107
3 changed files with 17 additions and 17 deletions

View File

@ -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. The following interactive session shows how to call them from Python.
.. code-block:: python .. code-block:: pycon
$ python $ python
>>> import example >>> 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 The Python session below shows how to override ``Animal::go`` and invoke it via
a virtual method call. a virtual method call.
.. code-block:: python .. code-block:: pycon
>>> from example import * >>> from example import *
>>> d = Dog() >>> d = Dog()
@ -834,7 +834,7 @@ Suppose we bind the following function
and call it from Python, the following happens: and call it from Python, the following happens:
.. code-block:: python .. code-block:: pycon
>>> v = [5, 6] >>> v = [5, 6]
>>> append_1(v) >>> append_1(v)
@ -863,7 +863,7 @@ functions:
In this case, properties can be read and written in their entirety. However, an In this case, properties can be read and written in their entirety. However, an
``append`` operaton involving such a list type has no effect: ``append`` operaton involving such a list type has no effect:
.. code-block:: python .. code-block:: pycon
>>> m = MyClass() >>> m = MyClass()
>>> m.contents = [5, 6] >>> 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 by the compiler. The result is returned as a NumPy array of type
``numpy.dtype.float64``. ``numpy.dtype.float64``.
.. code-block:: python .. code-block:: pycon
>>> x = np.array([[1, 3],[5, 7]]) >>> x = np.array([[1, 3],[5, 7]])
>>> y = np.array([[2, 4],[6, 8]]) >>> 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. in the function signature is generated using the object's ``__repr__`` method.
If not available, the signature may not be very helpful, e.g.: If not available, the signature may not be very helpful, e.g.:
.. code-block:: python .. code-block:: pycon
FUNCTIONS FUNCTIONS
... ...

View File

@ -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 is located in the current directory, the following interactive Python session
shows how to load and execute the example. shows how to load and execute the example.
.. code-block:: python .. code-block:: pycon
$ python $ python
Python 2.7.10 (default, Aug 22 2015, 20:33:39) 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 call the function using keyword arguments, which is a more readable alternative
particularly for functions taking many parameters: particularly for functions taking many parameters:
.. code-block:: python .. code-block:: pycon
>>> import example >>> import example
>>> example.add(i=1, j=2) >>> 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. The keyword names also appear in the function signatures within the documentation.
.. code-block:: python .. code-block:: pycon
>>> help(example) >>> help(example)
@ -201,7 +201,7 @@ using an extension of :class:`arg`:
The default values also appear within the documentation. The default values also appear within the documentation.
.. code-block:: python .. code-block:: pycon
>>> help(example) >>> help(example)

View File

@ -44,7 +44,7 @@ constructor's parameters as template arguments and wraps the corresponding
constructor (see the :ref:`custom_constructors` section for details). An constructor (see the :ref:`custom_constructors` section for details). An
interactive Python session demonstrating this example is shown below: interactive Python session demonstrating this example is shown below:
.. code-block:: python .. code-block:: pycon
% python % python
>>> import example >>> 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: Note how ``print(p)`` produced a rather useless summary of our data structure in the example above:
.. code-block:: python .. code-block:: pycon
>>> print(p) >>> print(p)
<example.Pet object at 0x10cd98060> <example.Pet object at 0x10cd98060>
@ -99,7 +99,7 @@ Lambda function instead:
Both stateless [#f1]_ and stateful lambda closures are supported by pybind11. Both stateless [#f1]_ and stateful lambda closures are supported by pybind11.
With the above change, the same Python code now produces the following output: With the above change, the same Python code now produces the following output:
.. code-block:: python .. code-block:: pycon
>>> print(p) >>> print(p)
<example.Pet named 'Molly'> <example.Pet named 'Molly'>
@ -120,7 +120,7 @@ method also exists for ``const`` fields.
This makes it possible to write This makes it possible to write
.. code-block:: python .. code-block:: pycon
>>> p = example.Pet('Molly') >>> p = example.Pet('Molly')
>>> p.name >>> 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, Functionality-wise, both approaches are completely equivalent. Afterwards,
instances will expose fields and methods of both types: instances will expose fields and methods of both types:
.. code-block:: python .. code-block:: pycon
>>> p = example.Dog('Molly') >>> p = example.Dog('Molly')
>>> p.name >>> p.name
@ -253,7 +253,7 @@ sequence.
The overload signatures are also visible in the method's docstring: The overload signatures are also visible in the method's docstring:
.. code-block:: python .. code-block:: pycon
>>> help(example.Pet) >>> 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 into the parent scope, which should be skipped for newer C++11-style strongly
typed enums. typed enums.
.. code-block:: python .. code-block:: pycon
>>> p = Pet('Lucy', Pet.Cat) >>> p = Pet('Lucy', Pet.Cat)
>>> p.type >>> p.type