Can I create object names from a text file in Python 2.7?
- by user560100
I'm working on a game project.
I've created an object, Star(Object).
I want to assign the name of the variables, dynamically, from a text file.
If I have a text file with:
Sol
Centauri
Vega
I want the program to create the Star(Object) with variable names from the text file. I want the process automated, because I'm looking to create hundreds of stars.
I could write the code out by hand:
Sol = Star(Sol)
Centauri = Star(Centauri)
Vega = Star(Vega)
But isn't there a way to automate this?
Essentially, what I eventually want is a tuple with the list of stars, as their own objects. Then, when I am doing game maintenance, I can just iterate over all the objects in the tuple.