Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > why no block comments in Python?

Reply
Thread Tools

why no block comments in Python?

 
 
John Salerno
Guest
Posts: n/a
 
      03-08-2006
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?
 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      03-08-2006
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.)

</F>



 
Reply With Quote
 
 
 
 
Roy Smith
Guest
Posts: n/a
 
      03-08-2006
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.
 
Reply With Quote
 
Fredrik Lundh
Guest
Posts: n/a
 
      03-08-2006
Roy Smith wrote:

> > you can quickly comment out regions by putting them
> > inside a triple-quoted string.)

>
> Except that triple-quotes don't nest.


''' """...except when they do""" '''

</F>



 
Reply With Quote
 
Warby
Guest
Posts: n/a
 
      03-08-2006
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.

 
Reply With Quote
 
Warby
Guest
Posts: n/a
 
      03-08-2006
....and I forgot to mention that the output of grep and diff is far more
understandable in the absence of block comments!

 
Reply With Quote
 
John Salerno
Guest
Posts: n/a
 
      03-08-2006
Warby wrote:

> 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.


That makes sense. If you have a modern editor, you don't need blocks. If
you don't have one, blocks don't help.
 
Reply With Quote
 
Roy Smith
Guest
Posts: n/a
 
      03-08-2006
Warby <> wrote:
>Eliminating block comments eliminates uncertainty.


An even better way to eliminate uncertainty is to eliminate the code.
Commenting out is fine for a quick test during development. Once the
code is committed, the dead code should be eliminated completely.

 
Reply With Quote
 
Terry Hancock
Guest
Posts: n/a
 
      03-09-2006
On Wednesday 08 March 2006 12:42 pm, Warby wrote:
> 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).


No doubt some Emacs zealot will say something snarky at this point,
but it's also true that Vi (or gvim anyway) will occasionally get
confused by very long block comments or triple-quoted strings,
causing the syntax-color to get out of synch.

I recently started running into this problem when I started using
doctest tests. There's probably a smarter way to do this, but I
was putting several of them in a module docstring, and it gets to
be a 100+ lines or so of doctest plus explanations.

I'm thinking this might be a use-case for the new support for
doctests in a separate file. Or maybe I just need to see if I
can move the tests into individual object docstrings.

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks http://www.anansispaceworks.com
 
Reply With Quote
 
Paddy
Guest
Posts: n/a
 
      03-09-2006
I have found that some editors colourize text based on parsing a
section of text around what is visible. Long, multi-line comments or
strings might not then get colored correctly.

Personally, I do use block comments in other languages but maybe they
should not exist in finished code for reasons already given by others,
readabiity!

Cheers, Paddy.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Fo:Block can you check to see if a block contains any text by using the block id? morrell XML 1 10-10-2006 07:18 PM
A program to replace all JS comments with JSP comments in jsp files tungchau81@yahoo.com Java 0 06-02-2006 06:35 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57