Kaydet (Commit) 3822af6d authored tarafından Andrew M. Kuchling's avatar Andrew M. Kuchling

Add *,**,@ to index, as suggested by

http://farmdev.com/thoughts/24/what-does-the-def-star-variable-or-def-asterisk-parameter-syntax-do-in-python-/

The right entry type to use isn't clear; operator seems wrong, because *,**,@
aren't being used in expressions here.  I put them as 'statement'; 'syntax'
might be better.
üst 09a1ebc9
...@@ -424,6 +424,9 @@ when the function is called. ...@@ -424,6 +424,9 @@ when the function is called.
The function definition does not execute the function body; this gets executed The function definition does not execute the function body; this gets executed
only when the function is called. only when the function is called.
.. index::
statement: @
A function definition may be wrapped by one or more :term:`decorator` expressions. A function definition may be wrapped by one or more :term:`decorator` expressions.
Decorator expressions are evaluated when the function is defined, in the scope Decorator expressions are evaluated when the function is defined, in the scope
that contains the function definition. The result must be a callable, which is that contains the function definition. The result must be a callable, which is
...@@ -464,6 +467,10 @@ as the default, and explicitly test for it in the body of the function, e.g.:: ...@@ -464,6 +467,10 @@ as the default, and explicitly test for it in the body of the function, e.g.::
penguin.append("property of the zoo") penguin.append("property of the zoo")
return penguin return penguin
.. index::
statement: *
statement: **
Function call semantics are described in more detail in section :ref:`calls`. A Function call semantics are described in more detail in section :ref:`calls`. A
function call always assigns values to all parameters mentioned in the parameter function call always assigns values to all parameters mentioned in the parameter
list, either from position arguments, from keyword arguments, or from default list, either from position arguments, from keyword arguments, or from default
......
...@@ -437,6 +437,9 @@ not done, the order in which the arguments are printed is undefined. ...@@ -437,6 +437,9 @@ not done, the order in which the arguments are printed is undefined.
Arbitrary Argument Lists Arbitrary Argument Lists
------------------------ ------------------------
.. index::
statement: *
Finally, the least frequently used option is to specify that a function can be Finally, the least frequently used option is to specify that a function can be
called with an arbitrary number of arguments. These arguments will be wrapped called with an arbitrary number of arguments. These arguments will be wrapped
up in a tuple. Before the variable number of arguments, zero or more normal up in a tuple. Before the variable number of arguments, zero or more normal
...@@ -464,6 +467,9 @@ or tuple:: ...@@ -464,6 +467,9 @@ or tuple::
>>> range(*args) # call with arguments unpacked from a list >>> range(*args) # call with arguments unpacked from a list
[3, 4, 5] [3, 4, 5]
.. index::
statement: **
In the same fashion, dictionaries can deliver keyword arguments with the ``**``\ In the same fashion, dictionaries can deliver keyword arguments with the ``**``\
-operator:: -operator::
......
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