What's the word on using """ to comment-out?

Grant Edwards invalid at invalid.invalid
Thu Feb 25 17:39:11 CET 2010

On 2010-02-25, Michael Rudolf <spamfresser at ch3ka.de> wrote:
> Am 25.02.2010 16:07, schrieb Grant Edwards:
>> On 2010-02-25, Paul Rudin<paul.nospam at rudin.co.uk>  wrote:
>>> No idea, but it would be nice to have some multiline comment syntax
>>> (other than # at the beginning of each line). Particularly one that can
>>> be nested.
>> if 0:
>> Seriously, that's what I generally do: mark the block of code,
>> indent it 1 level, add an if 0: at the top.
> I really hate it when I see something like this in other's
> code. 

The only time you'll see that in my code is if you're watching
over my shoulder as I troublshoot something.

> The fact that my IDE (vim) still displays this like valid code
> ready to be executed can cause extreme frustration while
> trying to spot a bug.

Nobody in their right mind _leaves_ "commented out" code like
that (or other commenting mechanisms) in a program after
they're done with whatever little experiment they were

I know people who will re-write a block of code and leave the
old code there, but comment it out, along with the date and
their name, and other such nonsense.  I hate that. Keeping
track of what _used_ to be there and who changed what when is
the job of the version control system.  Trying to keep the
edit-history of a file in-line as comments just makes the code
hard to read and maintain.

> This is almost as bad as "commenting out" (parts of) a for
> loop by adding a continue.

IMO, any sort of "commented out" code left in a program is a
big mistake.  If the code is soething that does need to stay
for optional use, then it needs to be properly integrated along
with logic to control when it's used.

Grant Edwards                   grante             Yow! Four thousand
                                  at               different MAGNATES, MOGULS
                               visi.com            & NABOBS are romping in my
                                                   gothic solarium!!

More information about the Python-list mailing list