@Robert Kern: "Multi-line string literals aren't comments. They are
multi-line string literals. Unlike a comment, which does not show up in
the compiled bytecode, the Python interpreter actually does something with
those string literals."
They have Guido's stamp of approval, and apparently the interpreter ignores
them: https://twitter.com/gvanrossum/status/112670605505077248
They feel like an ugly hack to me too, though.
@Robert Kern: "The main problem is that #: currently has a meaning as a
line comment. This could break existing code."
It could, but the only case I can see is when the comment isn't following
indentation convention:
#: Valid either way; next line's not indented,
#: so it's not counted as part of the block.
print('a')
# Causes an IndentationError in existing code.
#:
print('b')
def foo():
#: This one would break.
print('c')
On Fri, Jun 15, 2012 at 4:00 AM, <python-ideas-request@python.org> wrote:
Send Python-ideas mailing list submissions to
python-ideas@python.org
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/python-ideas
or, via email, send a message with subject or body 'help' to
python-ideas-request@python.org
You can reach the person managing the list at
python-ideas-owner@python.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-ideas digest..."
Today's Topics:
1. Multi-line comment blocks. (David Gates)
2. Re: Multi-line comment blocks. (Robert Kern)
----------------------------------------------------------------------
Message: 1
Date: Fri, 15 Jun 2012 02:49:18 -0600
From: David Gates <gatesda@gmail.com>
To: python-ideas@python.org
Subject: [Python-ideas] Multi-line comment blocks.
Message-ID:
<CAG2+q8Ska2HLksy6D49wOzgBbQ6E44xLFjqQyZRnhfJTywCmKw@mail.gmail.com
Content-Type: text/plain; charset="iso-8859-1"
Multi-line strings as comments don't nest, don't play well with docstrings,
and are counter-intuitive when there's special language support for
single-line comments. Python should only have one obvious way to do things,
and Python has two ways to comment, only one of which is obvious. My
suggestion is to add language support for comment blocks, using Python's
existing comment delimiter:
# Single-line comment
#:
Multi-line comment
#:
Nested multi-line comments work perfectly
Of course they do, they're just nested blocks
def foo():
"""Docstrings work perfectly. Why wouldn't they?"""
pass
# No need for an end-delimiter like """ or */