summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2005-11-22 19:50:22 (GMT)
committerGeorg Brandl <georg@python.org>2005-11-22 19:50:22 (GMT)
commitb058403576e26b99775ed6e5bed7cdfa8f2c8ddf (patch)
treeb60eece128cfe5f6462204a7566fd2ad4ed1376e /Doc
parent7bf4d580fa6d505cfce31f6173818844fce8ee1f (diff)
downloadcpython-b058403576e26b99775ed6e5bed7cdfa8f2c8ddf.zip
cpython-b058403576e26b99775ed6e5bed7cdfa8f2c8ddf.tar.gz
cpython-b058403576e26b99775ed6e5bed7cdfa8f2c8ddf.tar.bz2
added example for the ** operator in function calls
Diffstat (limited to 'Doc')
-rw-r--r--Doc/tut/tut.tex14
1 files changed, 14 insertions, 0 deletions
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex
index ae8fcf6..fcca541 100644
--- a/Doc/tut/tut.tex
+++ b/Doc/tut/tut.tex
@@ -1632,6 +1632,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}}