Best way to work in debug code?

rdudfield at my-deja.com rdudfield at my-deja.com
Tue Jan 18 20:10:05 EST 2000


Thanks alot for your reply, this is just what I was looking for :)

In article <slrn887f3r.viv.quinn at drachma.ugcs.caltech.edu>,
  quinn at drachma.ugcs.caltech.edu (Quinn Dunkan) wrote:
> On Mon, 17 Jan 2000 09:19:08 GMT, rdudfield at my-deja.com
> <rdudfield at my-deja.com> wrote:
> >Hello,
> >
> >
> >Just wondering how you people write debug code in your functions
> >/methods?
> >
> >I personally write a "if (DEBUG_LEVEL >= 5):" around the code.
However
> >this reduces readability.
>
> I have a dprint(msg) function that writes msg to stderr if debugging
is set,
> or to a file if debug_log is set, and occaisionally use assertions.
I've
> never found it useful to get more complicated than that.  The only
time I've
> found it useful is for long-running processes that try to do
complicated
> stuff.
>
> If you put code in if __DEBUG__: (or assert expr) then python -O will
> "optimize" it away.  If you don't want to see debugging stuff in code,
perhaps
> a folding editor is the way to go (vim will do it eventually).
>
> And then, if your code needs that much debugging, perhaps simplifying,
> componentizing, and writing test harnesses is a better solution.
>

That's one of my problems.  Componentizing that is.  If there is a stuff
up in one of my parts of my program it can often flow on to other parts.

I allready have a function to test most of the more than trivial
classes, and methods.

I don't use many assertions though, I might start putting them in.


Thanks again.

Rene.


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list