On May 20, 10:35 pm, Alex Hall <mehg...@gmail.com> wrote:

> So how do I get at anything inside **kw? Is it a list?

It's a dictionary.  Use *args for a list.  (As with self, the name is
whatever you want to use, but some sort of consistency is nice.)

One of the cool things about Python is how easy it is to play at the
command prompt:

>>> def foo(x=3, y=7):
...     print x,y
...
>>> def sam(**kw):
...     print kw
...     foo(**kw)
...

>>> sam(x=5)
{'x': 5}
5 7

>>> sam(y='hi there')
{'y': 'hi there'}
3 hi there

>>> sam(z=42)
{'z': 42}
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in sam
TypeError: foo() got an unexpected keyword argument 'z'
>>>


Regards,
Pat
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to