You can take a dictionary of key/value pairs and pass it to a function as keyword arguments:

def func(foo,bar):
        print foo, bar

args = {'foo':1, 'bar':2}

func(**args)

will print "1 2"

But what if you try passing those arguments to a function

def func2(bar,zoo=''):
        print bar, zoo

How can you determine that func2 will only accept
bar and zoo, but not foo and call the function with
bar as an argument?

I know CherryPy does this, but it's not obvious from the source
how they pulled it off.

-Dan


-- http://mail.python.org/mailman/listinfo/python-list

Reply via email to