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

Hugo Arts hugo.yoshi at gmail.com
Fri Sep 21 13:26:07 CEST 2012


On Fri, Sep 21, 2012 at 11:11 AM, Dae James <daedae11 at 126.com> wrote:

> **
> How can I convert a variable name to a string ?
> For example:
> testVariable = 1000;
> How can I get the string "testVariable" ?
> Thank you~
>
>
Well, the locals() dictionary will have a "testVariable" entry in it.. but
if I may ask, why would you want to do this? I see no reason this would
ever be necessary.

Hugo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120921/40db45a7/attachment.html>


More information about the Tutor mailing list