commenting out blocks of code
Peter Hansen
peter at engcorp.com
Fri Feb 17 19:12:01 EST 2006
john peter wrote:
> is there a similar mechanism in python, other than prefixing
> the '#' character to the start of each statement i do not
> want to execute (which gets old very quickly if one needs to
> comment and uncomment several statements a couple of
> times while "playing around with code" say during initial design)?
In addition to the approach Paul has suggested, you should also consider
using a better editor, as most decent editors should have some kind of
"block comment/uncomment" feature that prevents that operation from
getting old very quickly...
Scite, for example, lets me selected a block and hit Ctrl-Q to either
comment or uncomment the block. (It does this by prefixing each line
with #~ instead of just #, which allows it to detect when a line is
already so commented and reverse the operation.) Other decent editors
have their own approach.
-Peter
More information about the Python-list
mailing list