Styling Temporary Code

Aahz Maruch aahz at netcom.com
Thu Jun 1 17:44:50 EDT 2000


In article <3936A9BB.FBEF9201 at visionart.com>,
Pete Shinners  <pete at visionart.com> wrote:
>
>one thing i do frequenctly in C is to place temporary
>"debug/doublecheck/sanity" type code while i'm developing
>it. i always put this code in with no indenting, so it's
>easy to spot, work with, and cleanup. it looks something
>like this...
>
>
>int myfunc(int nullargs)
>{
>    int newval = do_fancy_stuff(nullargs);
>cout << "newval = " << newval << endl;
>    return more_fancy(newval);
>}
>
>
>ok, in this 5 line example it doesn't really sparkly,
>but when i use it in big sections of code, it can't
>be beat. call it the mark of the beast, chase me with
>pitchforks, i simply love it and i don't want to change!

This is one of the few areas where I think Python probably could use
some work.  A fair number of people on this newsgroup say that you
should just use a decent editor.

One person already suggested that you use assert.  Note that in Python
1.5.2 and later, you can turn off assert by setting the PYTHONOPTIMIZE
variable in addition to using -O on the command line.  You can also
express more complicated code with

if __debug__:
  ....

Both assert and "if __debug__" get optimized out with optimization
turned on.
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

Have you coined a word today?  --Aahz



More information about the Python-list mailing list