[Python-ideas] PEP 8 and long string literals

Gregory P. Smith greg at krypto.org
Mon Feb 25 15:00:50 EST 2019


On Mon, Feb 25, 2019 at 2:05 AM INADA Naoki <songofacandy at gmail.com> wrote:

> I think long URL in comment or docstring is good reason to ignore
> line length limit.
>

Yep, that's what we do in the yapf autoformatter.  There's good reason too,
source viewers and editors linkify URLs, if you break them across strings
to fit within a line length limit, you get a broken partial url.  It also
makes searching a codebase for references to specific identifiers much more
difficult if you've broken up their value at arbitrary points.

There are other examples for this such as allowing trailing line comments
for pylint, type checkers, etc. to go beyond 80 columns.

See the Exceptions in
https://google.github.io/styleguide/pyguide.html#32-line-length for what
make good practical examples.

I'm not convinced that codifying this in PEP-8 makes sense though unless we
see this happening within the Python standard library code itself (the
purpose of pep-8).  PEP-8 is not trying to be a style guide for all Python
users, just a stdlib style guide that happens to serve a base from which to
build upon.

-gps
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190225/e20d4aba/attachment.html>


More information about the Python-ideas mailing list