Group comment

ziaran nir1408 at ziaran.org
Mon Mar 1 16:30:15 CET 2004


Skip Montanaro wrote:
>     ketulp> Can I comment a group of statements together i.e
>     ketulp> If I a 4 statements say:
>     ketulp> i=1
>     ketulp> i+=1
>     ketulp> print i
>     ketulp> print i+1
> 
>     ketulp> Instead of commenting each satement iindividually by # is there
>     ketulp> something which allws me to comment these 4 statements in one go
>     ketulp> as in C++ using /*...*/
> 
> Many people use triple-quoted strings for this:
> 
>     """
>     i=1
>     i+=1
>     print i
>     print i+1
>     """
> 
> It's not a comment, strictly speaking, however it generally achieves the
> desired results.  Even less comment-like is "if False:":
> 
>     if False:
>         i=1
>         i+=1
>         print i
>         print i+1
> 
> That has the disadvantage that you need to reindent the lines of interest.
> 
> Skip
> 

And keep the """ at the same identation level of the clause!



More information about the Python-list mailing list