On 03/31/2014 04:12 PM, Chris Angelico wrote:
On Tue, Apr 1, 2014 at 9:57 AM, Ben Finney <ben+pyt...@benfinney.id.au> wrote:
Chris Angelico <ros...@gmail.com> writes:

How do you go about doing multi-line comments? I know I've seen other
code using triple-quoted strings for long comments before.

Just use a sequence of one-line comments::

     # Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a
     # sapien tempor, suscipit orci sed, elementum nisl. Suspendisse at
     # lacus ut diam dignissim lobortis ac vitae augue.
     #
     # Phasellus bibendum neque a justo vulputate, quis accumsan quam
     # egestas. Etiam aliquet blandit ante sit amet cursus.

A decent code editor (e.g. Emacs, Vim) will allow manipulation of
a sequence of one-line comments in Python's comment style, and allow
treating it as a paragraphs for purposes such as re-wrapping the lines.

I agree with others that triple-quoted strings are best reserved for
string literals (including docstrings), not comments.

Fair enough. I can't remember where (or when!) it was that I learned
triple-quoted strings were appropriately abused as comments, so I've
just done a quick re-layout into hash comments.

Personally, I use the sequence of one-line comments.

But, hey, Guido [1] himself likes the triple-quoted string as comment feature [2], so feel free to use it yourself if you like.

--
~Ethan~

[1] https://mail.python.org/pipermail/python-dev/2013-March/124947.html
[2] https://mail.python.org/pipermail/python-ideas/2009-October/006204.html
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to