Thanks a lot.<br>Please forgive my careless mistake, I am completely a new user^-^<br><br><div><span class="gmail_quote">2006/10/26, Fredrik Lundh <<a href="mailto:fredrik@pythonware.com">fredrik@pythonware.com</a>>:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">joe Li wrote:<br><br>> **class Bunch(object):<br>> def __init__(self, **fields):
<br>> self.__dict__ = fields<br>><br>> p = Bunch(x=2.3, y=4.5)<br>> print p<br>><br>> print p.__dict__<br>><br>> I dont' understand the usage of the double * here, could anyone explain<br>> it for me?
<br><br>if you're going to post questions to arbitrarily chosen threads, you<br>could at least change the subject (but it's a lot nicer to open a new<br>thread).<br><br>the "**" prefix tells Python to stuff any excess keyword arguments into
<br>the given variable:<br><br> >>> def func(**kwargs):<br>... print kwargs<br>...<br> >>> func()<br>{}<br> >>> func(spam=1, egg=2)<br>{'egg': 2, 'spam': 1}<br><br>for more on Python's parameter syntax, see the section on "def" in the
<br>language reference; see e.g.<br><br> <a href="http://effbot.org/pyref/def.htm">http://effbot.org/pyref/def.htm</a><br><br></F><br><br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list
</a><br></blockquote></div><br>