When to pull default values from a file?
<p>Not a specific coding question so much as program structure in general.</p>

<p>I'm one of those poorly self taught hobby programmers and I've got no idea what the best route is here. I want to create an object with 4 variables (name, objID, a, and b). For example:</p>

<pre><code>class myObj:
    def __init__(self, objName, objID):
        self.name = objName
        self.objID = objID
        self.a = 0
        self.b = 0
</code></pre>

<p>My question/problem is I want the initial values for a and b to be pulled from a .txt file, based on the value of objID. I actually want more than just 2 variables, and I'll be creating hundreds of these objects with a dozen different types.</p>

<p>I don't think I want to read the file from this class, as I believe it will reopen the file every time an object is created, and I don't really like pulling it into a list/array/dictionary and passing it to the class because the myObj class will only be called from an object above it, also with dozens of instances.</p>

<p>To clarify - I plan to create 100 'topObj' objects, each with 5-10 'myObj' objects, with each 'myObj' having starting values (that will change later), pulled from a text file, and I don't know when and where to read the data from the text file without reading it 500-1000 times.</p>

<p>Hopefully this makes some semblance of sense.</p>

<p>Thanks,<br>
db_</p>
