function arguments

Thomas Wouters thomas at xs4all.net
Thu Jul 6 07:19:18 EDT 2000


On Thu, Jul 06, 2000 at 12:57:49PM +0200, Johannes Zellner wrote:

> is there a way to get a functions argument list ?

> def fun(fred, lola):
>     ...

> something like `arglist(fun)' should return [ 'fred', 'lola' ]

If I'm not mistaken, that would be:

fun.func_code.co_varnames[:fun.func_code.co_argcount]

Except that it returns a tuple, not a list. dir() is your friend ;) Also,
you might want to look at the IDLE source for that kind of information.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list