Checking if a function invocation will throw a TypeError?

Andrey Fedorov anfedorov at gmail.com
Thu Oct 29 21:35:43 EDT 2009


Will do, thanks. Doing it to make a @curry decorator, which only executes a
function once enough arguments have been passed in.

- Andrey

On Thu, Oct 29, 2009 at 6:53 PM, Chris Rebert <clp2 at rebertia.com> wrote:

> On Thu, Oct 29, 2009 at 11:43 AM, Andrey Fedorov <anfedorov at gmail.com>
> wrote:
> > Is there a standard function that will check whether certain *args, and
> > **kwargs satisfy a argspec of a function (s.t. it does not throw a
> > TypeError). Say:
> >
> > def foo(a,b=1):
> >     pass
> >
> > check(foo, 1,2) # True
> > check(foo, 1) # True
> > check(foo) # False
> > check(foo, 1, a=2) # False
>
> Not that I know of, but you can write one yourself using
> inspect.getargspec():
> http://docs.python.org/library/inspect.html#inspect.getargspec
>
> Cheers,
> Chris
> --
> http://blog.rebertia.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091029/d2483449/attachment-0001.html>


More information about the Python-list mailing list