indirect **keyword calls
Wojtek Walczak
gminick at hacker.pl
Mon Nov 4 11:20:19 EST 2002
Dnia Mon, 28 Oct 2002 00:59:11 -0800, Terry Hancock napisał(a):
> I've just recently come across a need for this idiom (isn't
> this new in Python 2.x?):
> def my_func(spam, ham=1, **eggs):
> #...
> pass
There exist two ways of using dictionaries as arguments to functions.
Here we go with examples:
def first(**a):
print "\n".join([ "%s==%s" % (k,v) for k,v in a.items()])
first(a="b",b="c",c="d")
def second(a):
print "\n".join([ "%s==%s" % (k,v) for k,v in a.items()])
second({"a":"b", "b":"c", "c":"d"})
If you want to read more about it, take a look at
<http://diveintopython.org/>
--
[ Wojtek gminick Walczak ][ http://gminick.linuxsecurity.pl/ ]
[ gminick (at) hacker.pl ][ gminick (at) underground.org.pl ]
More information about the Python-list
mailing list