Retrieving a variable's name.

Steve Holden steve at holdenweb.com
Tue Aug 21 12:57:32 EDT 2007


rodrigo wrote:
> How would I go about retrieving a variable's name (not its value)? I
> want to write a function that, given a list of variables, returns  a
> string with each variable's name and its value, like:
> 
> a: 100
> b: 200
> 
> I get the feeling this is trivial, but I have been unable to find an
> answer on my own.
> 
So what would you want

     yourfunction(32)

to return? None?

Names in Python are references to values, and the same value can be 
reference by zero to many different names, so your request is close to 
nonsensical.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------




More information about the Python-list mailing list