[Python-ideas] Multi-line comment blocks.
Robert Kern
robert.kern at gmail.com
Fri Jun 15 11:50:40 CEST 2012
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
More information about the Python-ideas
mailing list