Interesting Syntax: 'Bunch' class
Remco Gerlich
scarblac at pino.selwerd.nl
Mon Apr 9 02:43:28 EDT 2001
Andy Todd <atodd at spam.free.email.com> wrote in comp.lang.python:
> From an earlier thread I picked up Alex Martelli's 'bunch' class from the
> Active State cookbook (
> http://www.activestate.com/ASPN/Python/Cookbook/Recipe/52308). I love this
> and will no doubt use it time and again. However, I'm puzzled by a bit of
> syntax that I haven't seen before and can't find (easily) in the manual,
> viz;
>
> " def __init__(self, **kwds):"
>
> What is the "**kwds" a reference to? All help greatfully received ...
A dictionary of keyword arguments.
Try
>>> def test(**kwds):
... print kwds
...
>>> test(a=3, b=4)
{'a': 3, 'b': 4}
--
Remco Gerlich
More information about the Python-list
mailing list