I''m still tyring to figure out what "Pythonic" means, and I have a
feeling the answer to my question may fall into that category. Are block
comments somehow unpythonic?
解决方案John Salerno wrote:
I''m still tyring to figure out what "Pythonic" means, and I have a
feeling the answer to my question may fall into that category. Are block
comments somehow unpythonic?
only in the sense that python don''t have them.
but they''re pretty pointless, if you have a modern editor.
(and if you don''t, you can quickly comment out regions by putting them
inside a triple-quoted string.)
Fredrik Lundh wrote:you can quickly comment out regions by putting them
inside a triple-quoted string.)
Except that triple-quotes don''t nest.
I do agree, however, with the idea that any decent editor should be
able to comment out a block of code faster than I can type this
sentence.
It''s clear that if you have a modern editor, block comments are
unnecessary because it is trivial to add a # to the start of each line
of a block, but that doesn''t really answer your question. It explains
why you might not always need block comments but doesn''t explain why
you shouldn''t use them (especially in a primitive editor).
The danger with block comments is that there is no way to tell that the
code you''re looking at has been commented out unless you can see the
start or end of the comment block. If you have a modern editor, it
probably changes the color of all commented out code to eliminate
confusion. But if you have a primitive editor it does not. Also, even
people who use modern editors sometimes browse source code using a
plain text viewer (less/more).
Eliminating block comments eliminates uncertainty. :)