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 doerwalter
Recipients doerwalter, r.david.murray
Date 2014-12-04.20:43:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The following doesn't work::

   import inspect

   def foo(*args, **kwargs):
      return (args, kwargs)

   # Code from to fill in the defaults

   sig = inspect.signature(foo)
   ba = sig.bind()

   for param in sig.parameters.values():
      if not in ba.arguments:
         ba.arguments[] = param.default

   print(foo(*ba.args, **ba.kwargs))

instead it gives the following traceback::

   Traceback (most recent call last):
     File "", line 16, in <module>
       print(foo(*ba.args, **ba.kwargs))
     File "/Users/walter/.local/lib/python3.4/", line 2246,    in args
   TypeError: 'type' object is not iterable

In my use case there isn't a call to a function implemented in Python. Instead I'm implementing a templating languages that supports defining a signature for a template. Calling the template binds the arguments and inside the template the variables simply are a dictionary.

I.e. define the template like this:

   t = Template("<?print a+b?>", signature="a, b=23")

Then you can call it like this:


and inside the template the variables will be {"a": 17, "b": 23}.

The signature argument in the Template constructor will be parsed into an inspect.Signature object and I'd like to use Signature.bind() to get the final variables dictionary.
Date User Action Args
2014-12-04 20:43:18doerwaltersetrecipients: + doerwalter, r.david.murray
2014-12-04 20:43:18doerwaltersetmessageid: <>
2014-12-04 20:43:18doerwalterlinkissue22998 messages
2014-12-04 20:43:18doerwaltercreate