Names of function's args?
Michael Hudson
mwh at python.net
Tue Jan 29 08:14:07 EST 2002
"vigasinus" <vi at rial.net> writes:
> Hello, All
>
> We can easily get names of function's arguments inside of a function
> body?
>
> >>> def f(arg1, arg2):
> ... print dir()
> ...
> >>> f(1,2)
> ['arg1', 'arg2']
>
> How to get them outside of a function?
>
> Thanks.
f.func_code.co_varnames[:f.func_code.co_argcount]
Is that what you meant?
Cheers,
M.
--
ARTHUR: Why should he want to know where his towel is?
FORD: Everybody should know where his towel is.
ARTHUR: I think your head's come undone.
-- The Hitch-Hikers Guide to the Galaxy, Episode 7
More information about the Python-list
mailing list