On 11/2/07, matthias <[EMAIL PROTECTED]> wrote: > Howdy ! > > I started using the assert() stmt and found it quite useful :-) I > have only one problem: I don't > know how to turn them off again. > > I know that "-O" turns off assertions in general. However, how do I > pass thus parameter to > python to an executable script ? > > I have tried the following: > > 1. > !#/usr/bin/env python -O > > -> Fails with this msg: /usr/bin/env: python -O: No such file or > directory > > Also, putting it in quotes won't do it. > > 2. > Passing the "-O" to the runnable script won't work either. > > > Here is my question: How do I maintain debug / release builds that > allow me to switch > debug stmts, like assert, on / off ? > > Thanx, > Matthias
Use: python -O -mcompileall path That command will compile all of the files in the given path and produce .pyo files. If the .pyo file is present and up-to-date it will be used instead of the .py file. Alternatively you could do this: python -O -mpy_compile somefile.py which can be used to compile one file at a time. Many Python programs and modules include a compile step as part of their installation process. There is also a -OO option, which will strip doc-strings as well. Matt -- http://mail.python.org/mailman/listinfo/python-list