Comments

Mark McEahern marklists at mceahern.com
Wed May 8 12:11:38 EDT 2002


[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

Cheers,

// mark





More information about the Python-list mailing list