diff options
author | Georg Brandl <georg@python.org> | 2005-11-22 19:50:14 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2005-11-22 19:50:14 (GMT) |
commit | 3c9f9ac62bb3b2f96a7735491a82ff57464371bb (patch) | |
tree | 79243977ef0ba17fb2754f7f3af0e70eb82e9e74 /Doc/tut/tut.tex | |
parent | 4bd165afa3100476d1018cc227186e60814e49cf (diff) | |
download | cpython-3c9f9ac62bb3b2f96a7735491a82ff57464371bb.zip cpython-3c9f9ac62bb3b2f96a7735491a82ff57464371bb.tar.gz cpython-3c9f9ac62bb3b2f96a7735491a82ff57464371bb.tar.bz2 |
Added example for the ** operator in function calls
Diffstat (limited to 'Doc/tut/tut.tex')
-rw-r--r-- | Doc/tut/tut.tex | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex index ee911b3..e3cb1de 100644 --- a/Doc/tut/tut.tex +++ b/Doc/tut/tut.tex @@ -1642,6 +1642,20 @@ are not available separately, write the function call with the [3, 4, 5] \end{verbatim} +In the same fashion, dictionaries can deliver keyword arguments with the +\code{**}-operator: + +\begin{verbatim} +>>> def parrot(voltage, state='a stiff', action='voom'): +... print "-- This parrot wouldn't", action, +... print "if you put", voltage, "volts through it.", +... print "E's", state, "!" +... +>>> d = {"voltage": "four million", "state": "bleedin' demised", "action": "VOOM"} +>>> parrot(**d) +-- This parrot wouldn't VOOM if you put four million volts through it. E's bleedin' demised ! +\end{verbatim} + \subsection{Lambda Forms \label{lambda}} |