[Python-Dev] More Python command-line features
Greg Ward
gward@cnri.reston.va.us
Wed, 8 Sep 1999 08:48:49 -0400
On 08 September 1999, Jim Fulton said:
>
> While we're talking about Python command-line features, I have a couple
> of requests that would make life alot easier for us.
>
> 1. I'd like the options given before the script name to
> be accessable to Python scripts. For example, in:
>
> python -O foo.py bar spam
>
> I'd like to have a sys variable that told me that the arguments
> ['-O'] were included before the arguments ['foo.py', 'bar', 'spam']
> (aka sys.argv). This is needed if I want to fork/exec (or span or
> whatever) Python with the same option.
Regarding -O, it would also be nice to have a higher-level way to find
out what optimization level the current interpreter is running under.
Currently, as I understand it, there's no way to predict whether
py_compile will generate .pyc or .pyo files, which is a minor annoyance
in the Distutils installation code. However, if Jim's mythical sys
variable is guaranteed to canonicalize Python's command-line options so
that something like
"-O" in sys.python_argv
would always answer this question, I'd be satisfied.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913