Getting the argument names passed to a function ?

Fredrik Lundh effbot at telia.com
Tue Apr 4 17:08:55 EDT 2000


Andreas Jung <ajung at sz-sb.de> wrote:
>
> def myfunc(arg1,arg2):
> ...
>
>
> a=1;b=2
> myfunc(a,b)
>
> Is it possible to get the name of variables that  were
> used as arguments to call myfunc(). myfunc() should be
> able to determine the names 'a' and 'b'. Don't ask
> me why I need this - it's for a worse Python hack :-)

short answer: no

longer answer: maybe, using the incredibly clever and
totally evil bytecodehacks stuff:

    http://bytecodehacks.sourceforge.net

</F>

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->





More information about the Python-list mailing list