function arguments
Alex Martelli
alex at magenta.com
Thu Jul 6 07:32:39 EDT 2000
Johannes Zellner <johannes at zellner.org> wrote in message
news:Pine.LNX.4.21.0007061257160.17492-100000 at krispc6.physik.uni-karlsruhe.d
e...
>
> Hello,
>
> is there a way to get a functions argument list ?
>
> e.g.
>
> def fun(fred, lola):
> ...
>
> something like `arglist(fun)' should return [ 'fred', 'lola' ]
>>> def fun(fred, lola):
... pass
...
>>> def arglist(fun):
... return fun.func_code.co_varnames
...
>>> arglist(fun)
('fred', 'lola')
>>>
It returns a tuple rather than a list, but that's easy
to remedy in the unlikely case it matters to you, of course.
Alex
More information about the Python-list
mailing list