names of parameters as string

andrea valle andrea.valle at unito.it
Fri Oct 29 12:31:02 EDT 2004


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 
invoke)

Best

-a-

On 29 Oct 2004, at 18:18, Richie Hindle wrote:

>
> [Andrea]
>> I'd like to access the parameter list of a function
>
> 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')
>
> -- 
> Richie Hindle
> richie at entrian.com
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>
Andrea Valle
Laboratorio multimediale "G. Quazza"
Facoltà di Scienze della Formazione
Università degli Studi di Torino
andrea.valle at unito.it


_____________________________________________________________________
For your security, this mail has been scanned and protected by Inflex



More information about the Python-list mailing list