This question already has an answer here:
- Why doesn't Python have multiline comments? 16 answers
Is there a mechanism to comment out large blocks of Python code?
Right now, the only ways I can see of commenting out code are to either start every line with a #
, or to enclose the code in triple quotes: """
.
The problem with these is that inserting #
before every line is cumbersome and """
makes the string I want to use as a comment show up in generated documentation.
After reading all comments, the answer seems to be "No".
In vi:
Then do
On Eric4 there is an easy way: select a block, type Ctrl+M to comment the whole block or Ctrl+alt+M to uncomment.
In Eclipse using PyDev, you can select a code block and press Ctrl + #.
Hide the triple quotes in a context that won't be mistaken for a docstring, eg:
or:
M-x comment-region, in Emacs' Python mode.
You can replace
comm
by a variable of your choice that is perhaps shorter, easy to touch-type, and you know does not (and will not) occur in your programs. Examples:xxx
,oo
,null
,nil
.