Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
e4913479
Commit
e4913479
authored
Jul 06, 2018
by
scoder
Committed by
GitHub
Jul 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2417 from gabrieldemarmiesse/test_language_basics_6
Added tests for "language basics" part 6
parents
bd25194d
bd536e61
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
13 deletions
+16
-13
docs/examples/userguide/language_basics/kwargs_1.pyx
docs/examples/userguide/language_basics/kwargs_1.pyx
+6
-0
docs/examples/userguide/language_basics/kwargs_2.pyx
docs/examples/userguide/language_basics/kwargs_2.pyx
+5
-0
docs/src/userguide/language_basics.rst
docs/src/userguide/language_basics.rst
+5
-13
No files found.
docs/examples/userguide/language_basics/kwargs_1.pyx
0 → 100644
View file @
e4913479
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
)
docs/examples/userguide/language_basics/kwargs_2.pyx
0 → 100644
View file @
e4913479
def
g
(
a
,
b
,
*
,
c
,
d
):
...
# We cannot call g with less verbosity than this.
foo
=
g
(
4.0
,
"something"
,
c
=
68
,
d
=
"other"
)
docs/src/userguide/language_basics.rst
View file @
e4913479
...
@@ -324,13 +324,9 @@ Keyword-only Arguments
...
@@ -324,13 +324,9 @@ Keyword-only Arguments
----------------------
----------------------
As in Python 3, ``def`` functions can have 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):
.. literalinclude:: ../../examples/userguide/language_basics/kwargs_1.pyx
...
# We cannot call f with less verbosity than this.
foo = f(4, "bar", c=68, e=1.0)
As shown above, the ``c``, ``d`` and ``e`` arguments can not be
As shown above, the ``c``, ``d`` and ``e`` arguments can not be
passed as positional arguments and must be passed as keyword arguments.
passed as positional arguments and must be passed as keyword arguments.
...
@@ -338,16 +334,12 @@ Furthermore, ``c`` and ``e`` are **required** keyword arguments
...
@@ -338,16 +334,12 @@ Furthermore, ``c`` and ``e`` are **required** keyword arguments
since they do not have a default value.
since they do not have a default value.
A single ``"*"`` without argument name can be used to
A single ``"*"`` without argument name can be used to
terminate the list of positional arguments::
terminate the list of positional arguments:
def g(a, b, *, c, d):
...
# We cannot call g with less verbosity than this.
.. literalinclude:: ../../examples/userguide/language_basics/kwargs_2.pyx
foo = g(4.0, "something", c=68, d="other")
Shown above, the signature takes exactly two positional
Shown above, the signature takes exactly two positional
parameters and has two required keyword parameters
parameters and has two required keyword parameters
.
Function Pointers
Function Pointers
-----------------
-----------------
...
...
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