[Tutor] How can I convert a variable name to a string?

Steven D'Aprano steve at pearwood.info
Fri Sep 21 16:00:50 CEST 2012


On 21/09/12 19:11, Dae James wrote:
> How can I convert a variable name to a string ?
> For example:
> testVariable = 1000;
> How can I get the string "testVariable" ?


You can't. Any value could have zero, one or many names, and there is no way
to go backwards from the object to the name.

What are you trying to do that you think you need this?



-- 
Steven


More information about the Tutor mailing list