how query function args

David Allen mda at idatar.com
Thu Mar 29 14:01:06 EST 2001


In article <3AC375A5.507C4D73 at abaqus-sn.com>, "david winkler"
<winkler at abaqus-sn.com> wrote:

> I need to query the names and values of a function's keyword arguments. I
> suspect that there is an easy way to do this but cannot find it.  Would
> someone care to make a suggestion?

This may help - you can pass all arguments as a 
dictionary:

def some_function(**dict):
  for key in dict.keys():
    print "%s %s" % (key, dict[key])


some_function(foo='bar', baz='quux', spam='eggs')

this will print:

foo bar
baz quux
spam eggs

If you do argument passing in this way, you can queyr
the arguments all you want and even use keynames as
strings of course.  Is this what you mean?

-- 
David Allen
http://opop.nols.com/
----------------------------------------
When everything's coming your way, you're in the wrong lane.



More information about the Python-list mailing list