Styling Temporary Code
Paul Hughett
hughett at mercur.uphs.upenn.edu
Thu Jun 1 16:48:36 EDT 2000
Pete Shinners <pete at visionart.com> wrote:
: I've been developing in C for several years and have
: really been enjoying python recently.
: 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);
: }
In C I habitually add a comment /* DEBUG */ to such code; then I
can use the search command in the editor to find all instances quickly.
A possible translation into Python would be
: int myfunc(int nullargs)
: {
: int newval = do_fancy_stuff(nullargs);
: cout << "newval = " << newval << endl; # DEBUG
: return more_fancy(newval);
: }
for a single line, or something like
: int myfunc(int nullargs)
: {
: int newval = do_fancy_stuff(nullargs);
# DEBUG
: cout << "newval = " << newval << endl;
# /DEBUG
: return more_fancy(newval);
: }
if you want to more explicitly mark the exact beginning and
end of the test code.
Paul Hughett
More information about the Python-list
mailing list