Embedded comments in Python?

David Goodger goodger at python.org
Mon May 3 08:44:50 EDT 2004


Ernie wrote:
> Whats the legal way in Python to embed comments in Python code? 
> Example:
> 
> def foo(a <:int>, b <:float>): <:array>
>      return [a, b] 

def foo(a, #int
	b  #float
	): #array
     return [a, b]

Or better yet, put it all in a docstring:

def foo(a, b):
     """Given an int and a float, returns an array of [int, float]."""
     return [a, b]

> In C/C++, this would be no problem with /* */.

This is not C/C++.  In Python, comments begin with a "#" and end
at the end of the line.  That's it.

-- David Goodger





More information about the Python-list mailing list