Commit e4913479 authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2417 from gabrieldemarmiesse/test_language_basics_6

Added tests for "language basics" part 6
parents bd25194d bd536e61
def f(a, b, *args, c, d = 42, e, **kwds):
...
# We cannot call f with less verbosity than this.
foo = f(4, "bar", c=68, e=1.0)
def g(a, b, *, c, d):
...
# We cannot call g with less verbosity than this.
foo = g(4.0, "something", c=68, d="other")
......@@ -324,13 +324,9 @@ Keyword-only Arguments
----------------------
As in Python 3, ``def`` functions can have keyword-only arguments
listed after a ``"*"`` parameter and before a ``"**"`` parameter if any::
listed after a ``"*"`` parameter and before a ``"**"`` parameter if any:
def f(a, b, *args, c, d = 42, e, **kwds):
...
# We cannot call f with less verbosity than this.
foo = f(4, "bar", c=68, e=1.0)
.. literalinclude:: ../../examples/userguide/language_basics/kwargs_1.pyx
As shown above, the ``c``, ``d`` and ``e`` arguments can not be
passed as positional arguments and must be passed as keyword arguments.
......@@ -338,16 +334,12 @@ Furthermore, ``c`` and ``e`` are **required** keyword arguments
since they do not have a default value.
A single ``"*"`` without argument name can be used to
terminate the list of positional arguments::
def g(a, b, *, c, d):
...
terminate the list of positional arguments:
# We cannot call g with less verbosity than this.
foo = g(4.0, "something", c=68, d="other")
.. literalinclude:: ../../examples/userguide/language_basics/kwargs_2.pyx
Shown above, the signature takes exactly two positional
parameters and has two required keyword parameters
parameters and has two required keyword parameters.
Function Pointers
-----------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment