A case for "real" multiline comments

Devin Jeanpierre jeanpierreda at gmail.com
Thu Apr 19 08:15:23 EDT 2012


On Thu, Apr 19, 2012 at 2:56 AM, Chris Angelico <rosuav at gmail.com> wrote:
> So, here's a proposal. (Maybe I should take this part to another list
> or the Python issue tracker.) Introduce a new keyword or reuse
> existing keywords to form a marker that unambiguously says "Ignore
> these lines" and then subsequently "Stop ignoring lines". These
> markers must go on their own lines, optionally with whitespace and/or
> a one-line comment, but nothing else. This could accidentally
> terminate or nest if a triple-quoted string contains Python code, but
> that would always be an issue.
>
---------8<---------
>
> The exact choice of keywords is open to discussion, I just looked at
> keyword.kwlist on my Python 3.2 and tried to come up with something.
> This syntax looks like it wouldn't nest, so it's unideal for the
> proposal.
>
> Does Python need multi-line code removal? And if so, will something
> like this work?

Two questions:

Why don't you allow nested multiline comments? Many languages (e.g.
ML, Scheme, Haskell, etc.) allow you to nest multi-line comments. It's
mostly the C family of languages that refuse to do this, AFAIK.

Least importantly: Why are multiline comments line-oriented? Why not
inline, like with the C-style /* ... */ comments? This doesn't seem
like a "proper" multiline comment.

-- Devin



More information about the Python-list mailing list