doc strings should not be accessed? -OO

Thomas Heller theller at python.net
Tue Feb 10 14:57:07 EST 2004


George Young <gee_arr_why at ll.mit.edu> writes:

> [python 2.3.3, SuSE 8.2 x86 Linux]
> In setting up an install procedure for the "released" directory
> of my app, I found that after doing:
>
>   python -OO -c 'import compileall;compileall.compile_dir(".")'
>
> in my Makefile (I know, I'll switch to distutils sometime...),
> my app doesn't print the proper "usage" message when invoked
> with improper args.  The app is using the module's __doc__ 
> string as part of it's "usage" message.  
>
> I see from the docs that -OO or PYTHONOPTIMIZE=2 removes 
> the __doc__ string.  It seems to me that either:
>
> 1) there should be clear and prominent warning where docstrings
> are discussed in the manual that they may not be available
> during execution, or
>
> 2) optimization should leave the poor things alone...
>
> Coming from many years of c and c++ programming where "if 
> cranking up the optimization changes the output, the compiler
> is broken" -- it seems to violate the friendliness of python's
> style...

The *sole purpose* of '-OO' against '-O' is to remove the doc strings.
You should not give any switches to Python when you're not knowing what
they do...

Thomas



More information about the Python-list mailing list