Assertion for python scripts
Carl Banks
pavlovevidence at gmail.com
Mon Nov 5 06:41:33 EST 2007
On Nov 2, 11:22 pm, Carl Banks <pavlovevide... at gmail.com> wrote:
> On Nov 2, 2:14 pm, matthias <matthiasblankenh... at yahoo.com> wrote:
>
> > Here is my question: How do I maintain debug / release builds that
> > allow me to switch
> > debug stmts, like assert, on / off ?
>
> If you want to distribute a single-file optimized version, perhaps
> embedding the Python code as a here-file in a shell script would work
> for you. For example:
>
> #!/bin/sh
> exec python -O <<EOF
>
> assert False
>
> EOF
Not long after I made this suggestion, I suddenly found myself in a
situation where I wanted to do something like this (temporarily: I
needed to disable a pointer check that a buggy C++ extension was
causing). Here's what I ended up with, after falling in a few pits:
#!/bin/sh
MALLOC_CHECK_=0 /usr/bin/python2.4 - "$@" <<'SCRIPT'
<script goes here>
SCRIPT
Carl Banks
More information about the Python-list
mailing list