[Python-ideas] Python-ideas Digest, Vol 67, Issue 51

David Gates gatesda at gmail.com
Fri Jun 15 13:47:57 CEST 2012


@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 at python.org> wrote:

> Send Python-ideas mailing list submissions to
>        python-ideas at 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 at python.org
>
> You can reach the person managing the list at
>        python-ideas-owner at 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 at gmail.com>
> To: python-ideas at python.org
> Subject: [Python-ideas] Multi-line comment blocks.
> Message-ID:
>        <CAG2+q8Ska2HLksy6D49wOzgBbQ6E44xLFjqQyZRnhfJTywCmKw at 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 */
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/python-ideas/attachments/20120615/84005c9f/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Fri, 15 Jun 2012 10:50:40 +0100
> From: Robert Kern <robert.kern at gmail.com>
> To: python-ideas at python.org
> Subject: Re: [Python-ideas] Multi-line comment blocks.
> Message-ID: <jrf0hg$sj4$1 at dough.gmane.org>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 6/15/12 9:49 AM, David Gates wrote:
> > 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.
>
> 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. Sometimes
> people
> abuse them as ways to poorly emulate block comments, but this is an abuse,
> not a
> feature of the language.
>
> > 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 */
>
> The main problem is that #: currently has a meaning as a line comment. This
> could break existing code.
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma
>  that is made terrible by our own mad attempt to interpret it as though it
> had
>  an underlying truth."
>   -- Umberto Eco
>
>
>
> ------------------------------
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
>
> End of Python-ideas Digest, Vol 67, Issue 51
> ********************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120615/9d0b9cc9/attachment.html>


More information about the Python-ideas mailing list