This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author gsakkis
Recipients gsakkis
Date 2008-06-18.22:16:50
SpamBayes Score 0.025244616
Marked as misclassified No
Message-id <1213827414.08.0.250071294589.issue3135@psf.upfronthosting.co.za>
In-reply-to
Content
I'd like to propose a new function for inclusion to the inspect module
-- getcallargs(func, *args, **kwds) -- that returns a dict which maps
the formal arguments of a function (or other callable) to the values
passed as args and kwds, just as Python has to do when calling
func(*args, **kwds). For example:

>>> def func(a, b='foo', c=None, *x, **y):
...         pass
>>> sorted(getcallargs(func, 5, z=3, b=2).items())
 [('a', 5), ('b', 2), ('c', None), ('x', ()), ('y', {'z': 3})]

This is handy when writing decorators, or more generally when one would
want to do some minimal type checking without actually calling the function.

I have posted a recipe at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/551779; I can
clean it up and submit a proper patch if it's deemed useful enough for
the stdlib.
History
Date User Action Args
2008-06-18 22:16:54gsakkissetspambayes_score: 0.0252446 -> 0.025244616
recipients: + gsakkis
2008-06-18 22:16:54gsakkissetspambayes_score: 0.0252446 -> 0.0252446
messageid: <1213827414.08.0.250071294589.issue3135@psf.upfronthosting.co.za>
2008-06-18 22:16:52gsakkislinkissue3135 messages
2008-06-18 22:16:51gsakkiscreate