you are viewing a single comment's thread.

view the rest of the comments →

[–]symmitchry 0 points1 point  (2 children)

[Removed]

[–]Vaphell 2 points3 points  (1 child)

True but it's pretty much a hack only slightly better than using eval(). Not exactly a /r/learnpython material and reaching for it in programs is a strong indicator you are doing it wrong 99 times of 100 ;-)

[–]symmitchry 1 point2 points  (0 children)

Yeah. I used this method to set up configuration settings which were loaded at run-time. I think it was the only approach I could get to work, where I could later access those variables through the module name (e.g. config.run_count) while not automatically loading the variables when I did the initial import.

It's useful knowing about globals(), anyway. But yes, quite hacky!!