On 4/18/07, <b class="gmail_sendername">Thomas Heller</b> <<a href="mailto:email@example.com">firstname.lastname@example.org</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Sometimes I think it would be great if it were possible to have standard<br>Python command line options that would allow<br><br>- initialize and configure the logging module<br>- specify requirements for pkg_resources (for eggs installed with --multi-version
<br><br>All this would avoid having to change logging options or requirements in the<br>script, or having to implement a command line parser for this stuff in every script.<br>The idea is to call python in this way:<br><br>
python --require foo==dev --logging level=DEBUG myscript.py<br><br><br><br>I have not been able to implement something like this in sitecustomize.py,<br>because this module is executed when sys.argv is not yet available.
<br><br>Another possible way to implement this would probably be to set environment vars<br>and parse those in sitecustomize.py, you would have to call<br><br> env option1=foo option2=bar python script.py<br><br>then; unfortuately windows does not have an 'env' utility.
<br><br>Does this sound like a useful idea?<br><br>Thomas</blockquote><div><br>-1 on this. IMHO these options are too specific to be part of Python's standard command line options. And using environment variables as a workaround... would cause all sorts of problems, like the one you mentioned.
<br><br>If these are options you often use for different Python scripts, you could create a generic Python script runner which would parse these options, initialize whatever is required (logging, packages, etc.) and finally execfile the given Python script. For example:
<br><br>script_runner.py --require foo==dev --logging level=DEBUG myscript.py<br><br>- Tal<br></div></div>