[Python-ideas] Multi-line comment blocks.

Guido van Rossum guido at python.org
Fri Jun 15 18:43:35 CEST 2012


Let's not try to design a syntax for multi-line comments. There are
already enough ways to emulate them. Designing a new syntax based on #
plus some special character is doomed for backwards compatibility
(never mind the clever tricks proposed).

--Guido

On Fri, Jun 15, 2012 at 9:23 AM, David Gates <gatesda at gmail.com> wrote:
> I agree that using multi-line strings as literals comes across as an ugly
> hack, even if it is BDFL-approved.
>
> Your other point is valid, though as far as I can tell it's only an issue
> when the comment is indented less than it ought to be (and starts with "#:",
> of course):
>
> #: Valid either way. The next line has the
> #: same level of indentation, 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 8:04 AM, Robert Kern <robert.kern at gmail.com> wrote:
>>
>> On 6/15/12 11:49 AM, Sven Marnach wrote:
>>>
>>> Robert Kern schrieb am Fri, 15. Jun 2012, um 10:50:40 +0100:
>>>>
>>>> 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.
>>>
>>>
>>> Multi-line string literals do not generate code in CPython, and their
>>> use as comments has BDFL approval:
>>>
>>>     https://twitter.com/gvanrossum/status/112670605505077248
>>
>>
>> Well fancy that.
>>
>> --
>> 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
>
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list