String representation of an identifier's name

John Roth johnroth at ameritech.net
Sun Jan 12 17:54:51 EST 2003


"Boethius" <boethius at techie.com> wrote in message
news:67446a0a.0301121334.22fe0673 at posting.google.com...
> I think it easier to explain with an example, so here it goes:
> Assuming there's a function fn that does what I want, it would work
like this:
>
> g = 23
> foo = {'a':56}
>
> fn(g) => 'g'
> fn(foo) => 'foo'
>
> How can I write fn? O:-)

In the Python Library Reference, look at the "inspect"
module. It's 3.11 in Python 2.2.2

I believe you want the "getargvalues" function.

HTH
John Roth






More information about the Python-list mailing list