Greg Ward wrote: > > 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. Check out mxTools (from my Python Pages). It has a function which lets you control the value of the optimization flag: """ The following functions are installed as add-ons to the builtin sys module. sys.verbosity([level]) If level is given, the value of the interpreter's verbosity flag is set to level and the previous value of that flag is returned. Otherwise, the current value is returned. You can use this function to e.g. enable verborse lookup output to stderr for import statements even when the interpreter was not invoked with '-v' or '-vv' switch or to force verbosity to be switched off. sys.debugging([level]) If level is given, the value of the interpreter's debugging flag is set to level and the previous value of that flag is returned. Otherwise, the current value is returned. You can use this function to check whether the interpreter was called with '-d' flag or not. Some extensions use this flag to enable/disable debugging log output (e.g. all the mx Extensions). sys.optimization([level]) If level is given, the value of the interpreter's optimization flag is set to level and the previous value of that flag is returned. Otherwise, the current value is returned. You can use this function to e.g. compile Python scripts in optimized mode even though the interpreter was not started with -O. """ -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 123 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4