names of parameters as string
jcarlson at uci.edu
Fri Oct 29 20:41:08 CEST 2004
andrea valle <andrea.valle at unito.it> wrote:
> Richie thanks a lot, it works perfectly.
> Anycase, I don't know exactly what's happening.
> Could you be so kind to comment the code?
> (or to point to some docs: I wasn't able to found the refercence. I
> found func_code before writing to the list, but not the method you
> On 29 Oct 2004, at 18:18, Richie Hindle wrote:
> > You can do it like this:
> >>>> def foo(foo_param1, foo_param2):
> > ... foo_local = foo_param1
> > ...
> >>>> code = foo.func_code
> >>>> print code.co_varnames[:code.co_argcount]
> > ('foo_param1', 'foo_param2')
He's not invoking any method explicitly. foo.func_code.co_varnames is a
tuple of names in the local scope of the foo() call. The first
foo.func_code.co_argcount entries are the argument names of the function
More information about the Python-list