[Python-checkins] commit of r41520 - python/branches/release24-maint/Doc/tut

reinhold.birkenfeld@python.org reinhold.birkenfeld at python.org
Tue Nov 22 20:50:29 CET 2005


Author: reinhold.birkenfeld
Date: Tue Nov 22 20:50:22 2005
New Revision: 41520

Modified:
   python/branches/release24-maint/Doc/tut/tut.tex
Log:
added example for the ** operator in function calls



Modified: python/branches/release24-maint/Doc/tut/tut.tex
==============================================================================
--- python/branches/release24-maint/Doc/tut/tut.tex	(original)
+++ python/branches/release24-maint/Doc/tut/tut.tex	Tue Nov 22 20:50:22 2005
@@ -1632,6 +1632,20 @@
 [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}}
 


More information about the Python-checkins mailing list