Python Freezing: general process and user input?
<p>I'm relatively new to the process of freezing and packaging code, and one of my concerns with freezing my project is how I'd deal with user input.  I have a main file in a project that deals with physics stuff with an input area like this: </p>

<pre><code>#Coil(center, radius, normal vector, current, scene, loops(default=1), pitch(default=1))

#Example coil:
r = Coil(vector(0, 0, 0), 10, vector(0, 1, 1), 10, d, 10, 0.5)
</code></pre>

<p>So after I package the file with py2exe or anything similar I find, is there a way to have the user input like the above, or do I need to create a user interface for that before packaging the code?  Thanks!</p>

<p>Once your code is frozen the contents of the code can no longer be changed, (without going back to the original code), but there are a number of strategies that you can use:</p>

<ul>
<li>Prompt the user for <em>missing</em> parameters one at a time - <em>makes the program hard to use</em></li>
<li>Allow the user to supply the parameters on the command line e.g.: using <a href="https://docs.python.org/3/library/argparse.html" rel="nofollow">argparse</a> - <em>enables batch calling of your code - can be combined with the above</em></li>
<li>Allow the user to supply a file containing the parameters this could be one per line, a line of comma separated parameters and call your function once per line or a multitude of other options like xml, ini format, etc. - <em>better batch calling - this can be combined with both of the above and you could have a <code>--file</code> option</em></li>
<li>All of the above <em>Possibly the best option</em></li>
<li>Provide a GUI input for parameters using Tinker, QT or wxPython <em>often the most work can still be combined with the above</em></li>
<li>You <em>can</em> implement a plug-in like architecture to supply default code but also allow the user to supply alternative code but there are security concerns.</li>
<li>You could leave the above code out of your frozen application but include it as a .py file that the user could modify <strong><em>beware</em></strong> <em>the user will have the full power of python available, including any libraries that your application includes which can make for malicious changes</em></li>
<li>You can write your own little language to allow the user to supply the items needed using e.g. by using <a href="https://github.com/igordejanovic/textX" rel="nofollow">TextX</a> or just about any of the tools listed <a href="https://wiki.python.org/moin/LanguageParsing" rel="nofollow">here</a> then allow the user to supply input file(s).</li>
</ul>

<p>Reading between the lines it looks like the user specifies a number of object instances which are then created and processed so a little pseudo language that you parse, <em>either from command line parameters or from a file</em>, would be the way to go. Then you parse, (and validate), the input and for each object create an instance and add it to a list. Then <em>once the input has been consumed</em> process all of the instances in the list.</p>

python python-2.7 vpython code-freeze