Comments

phil hunt philh at cabalamat.org
Tue Apr 1 11:34:34 EST 2003


On Tue, 1 Apr 2003 08:39:43 +0000 (UTC), Klaus Alexander Seistrup <spam at magnetic-ink.dk> wrote:
>Chris wrote:
>
>> I would like to request that Python support multi-line
>> comments (e.g. /* */ in C).
>
>You could always enclose comments in triple-quotes:
>
>#v+

What does this mean?

>comment = """
>Sed ut perspiciatis, unde omnis iste natus error sit voluptatem
> [...]

Or just:

"""
This is a comment
"""

To make it more obvious where the comment begins/ends, I sometimes 
use:

"""*****
This is a multi-line comment.
Here is some more text, etc, etc, etc.
*****"""

Incidently, do other people often use comments to denote the data-type of 
parameters or instance variables, e.g.:

def filenameToHtml(fn):
   """ Remove any extension on a filename, and replace it with an .html
       extension.
   @param fn [string] = a filename
   @return [string] = a filename    
   """
   rightmostDot = string.rfind(fn, ".")
   if rightmostDot == -1:
      return fn + ".html"
   else:
      return fn[:rightmostDot] + ".html"   

def timeToStr(t):
   """ return a string representing a time 
   @param t [int]  = time in seconds since start of Unix Epoch
   @return [string]
   """
   fmt = "%a, %Y %b %d, %H:%M UCT"
   return time.strftime(fmt, time.gmtime(t))



-- 
Philip Hunt <philh at cabalamat.org>

Interested in adventure holidays in Spain? 
Look at: <http://www.cabalamat.org/advcon/>




More information about the Python-list mailing list