block comments

Thomas Wouters thomas at xs4all.net
Sat Jun 17 14:36:51 EDT 2000


On Sat, Jun 17, 2000 at 06:22:56PM +0000, Pete Shinners wrote:
> as i get working with python more i start to miss the
> block commenting i had in C/C++

> i'm just doublechecking.. is there a block comment
> symbol in python? i'd like to commentout a large
> chunk of code with a simple start/end comment.

Triple quotes may be what you want. Oh wait ;)

> thinking about it, i suppose i could use the triple
> quotes to simply turn a large chunk of code into a
> string. is there a better way?

I usually use normal comments: my editor makes it fairly easy to add '#' (I
usually use ' ## ' to make clear that it's intended as a mass-comment-out)
at the start of each line in a particular block.

> should python have block comments? (py3k) and if it
> does there must be an answer to the eternal question...
> Are the block comments nestable?

The problem with block quotes is exactly that ;) One of the reasons C++ (and
ISO C) have the '//' line-comment (that lasts until the end of the line) is
the large number of problems that arrise when you try to quote a block of
code that has a comment in it, or accidentily screw up an end-marker (thus
leaving all code until the next end-marker commented out.)

This is why I prefer just adding ' ## ' to the start of each line i want to
block-comment-out. It *does* nest :-)

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list