From: Georg Brandl Date: Tue, 22 Nov 2005 19:50:14 +0000 (+0000) Subject: Added example for the ** operator in function calls X-Git-Tag: v2.5a0~1119 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3c9f9ac62bb3b2f96a7735491a82ff57464371bb;p=thirdparty%2FPython%2Fcpython.git Added example for the ** operator in function calls --- diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex index ee911b3ef3e4..e3cb1de5c46b 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}}