Hi, I am wondering if there is a way to somehow look at the contents of a variable and make a variable name with the contents of that variable. I really don't know how else to word that, just wondering. If anyone understands what I am saying and knows an answer please post. Thanks, 26bm
26bm 0 Newbie Poster
Recommended Answers
Jump to PostIt is possible for global variables
>>> varname = 'thevalue' >>> globals()[varname] = 3.14 >>> thevalue 3.14
In principle it doesn't work for local variables. Dictionaries returned by
locals()
are read-only.
All 3 Replies
Gribouillis 1,391 Programming Explorer Team Colleague
26bm 0 Newbie Poster
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.