Comments
Sean 'Shaleh' Perry
shalehperry at attbi.com
Wed May 8 12:20:42 EDT 2002
On 08-May-2002 Mark McEahern wrote:
> [Rajat Chopra]
>> Does anyone know if Python supports multi-line comments? I believe Java
>> and C++ (and even non-ANSI C) have /* ... */ for multi-line. Does Python
>> have anything comparable?
>
> Short answer: No.
>
> Long answer:
>
> Use the triple-quoted string; e.g.,
>
> def add(x, y):
> """Return the sum of x and y."""
>
> """
> Note: The first string in a method is considered the docstring.
> This here
> is effectively
> a multi-line
> comment.
> Fancy, neh?
> """
> return x + y
>
Sure, but comments are basically free whereas the above creates an anonmymous
string which has to be garbage collected.
Most scripting languages only support single line comments (usually with #).
/*
* I am ANSI C, hear me fly!
* and FLY!
*/
is not all that different from
# blah
# blah
# blah
if you need the visual difference, use 2 #'s.
## blah
## blah
## blah
More information about the Python-list
mailing list