Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51513

Re: PEP8 79 char max

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <joshua.landau.ws@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.024
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'else:': 0.03; 'broken': 0.04; 'nested': 0.07; 'arguments': 0.09; 'snippet': 0.09; 'cc:addr :python-list': 0.11; 'random': 0.14; '&gt;&gt;': 0.16; 'brackets,': 0.16; 'count.': 0.16; 'doing,': 0.16; 'imo,': 0.16; 'limit,': 0.16; 'readability': 0.16; 'readable': 0.16; 'rule.': 0.16; 'tab': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'uses,': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'trying': 0.19; 'fit': 0.20; 'email addr:gmail.com&gt;': 0.22; 'preferred': 0.22; 'putting': 0.22; 'tests': 0.22; 'cc:addr:python.org': 0.22; 'case.': 0.24; 'stick': 0.24; 'mon,': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; "i've": 0.25; '&gt;': 0.26; 'possibly': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'rest': 0.29; 'character': 0.29; 'characters': 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; "i'm": 0.30; 'code': 0.31; 'lines': 0.31; 'base,': 0.31; 'breaking': 0.31; "d'aprano": 0.31; 'indentation': 0.31; 'steven': 0.31; 'lists': 0.32; 'skip:c 30': 0.32; 'entirely': 0.33; 'skip:b 30': 0.33; "i'd": 0.34; 'classes': 0.35; 'possible.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'possible': 0.36; 'should': 0.36; 'unit': 0.37; 'two': 0.37; 'skip:& 10': 0.38; 'e.g.': 0.38; 'skip:[ 10': 0.38; 'pm,': 0.38; 'rather': 0.38; 'skip:& 20': 0.39; '8bit%:6': 0.40; 'skip:c 50': 0.60; 'units': 0.60; 'break': 0.61; 'length': 0.61; 'simply': 0.61; "you're": 0.61; 'personal': 0.63; 'such': 0.63; 'july': 0.63; 'for:': 0.64; 'become': 0.64; 'more': 0.64; 'natural': 0.68; 'line,': 0.68; 'deeply': 0.69; 'jul': 0.74; 'ambiguous': 0.84; 'limits,': 0.84; 'longest': 0.84; 'placement': 0.84; 'plays': 0.84; 'quicker': 0.84; 'absolutely': 0.87; '2013,': 0.91; 'joel': 0.91; 'choice.': 0.93; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=c7pLN0P/U3TzFuvpmkfGZNBNkqDUpHNlH+cRe9MqlI4=; b=ji5iPOasbDwRy0fE5/N+q2niAodTdQfnAC8P53FKHTNPu/gNRnwbhXhrSUcEPn3wnz 23UZsJNC2zLPUY6OgQ2taQzoLdhtMqTHKZetEDGglwZa9MX87rSeShimHxdFFfpHsQGA nDui8BUhKQjigl/5lnKr421bnZPwPSYzC/zniBcR0tPR05K8r7n4OPalOB3YOxxOyG/Q U/txQ1+PvQKWssyLn+qq6NCcxiweMAwWAv6LLzwNIh2HLB6GNvTmzkmG6z55MGv5QsAX HiXmeLduP0LymspodOJRsWUUPNEtyetoTbu2OvNBv4XmxiDaHrGvfpsASgtETwYJqzVb 4Exw==
X-Received by 10.112.52.97 with SMTP id s1mr26628574lbo.8.1375136719309; Mon, 29 Jul 2013 15:25:19 -0700 (PDT)
MIME-Version 1.0
Sender joshua.landau.ws@gmail.com
In-Reply-To <51f6dff4$0$30000$c3e8da3$5496439d@news.astraweb.com>
References <51F6C5F5.5020201@Gmail.com> <CAPM-O+y++Q499zgYBGxTdPhLX9D_CfOwHnRTTo+ncQrPVFpD7g@mail.gmail.com> <mailman.5266.1375129541.3114.python-list@python.org> <51f6dff4$0$30000$c3e8da3$5496439d@news.astraweb.com>
From Joshua Landau <joshua@landau.ws>
Date Mon, 29 Jul 2013 23:24:39 +0100
X-Google-Sender-Auth uYo5hExIFwrhTVZza9u1MksdKz4
Subject Re: PEP8 79 char max
To "Steven D'Aprano" <steve+comp.lang.python@pearwood.info>
Content-Type multipart/alternative; boundary=001a11c3ecdeac158a04e2adf700
Cc python-list <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5280.1375137148.3114.python-list@python.org> (permalink)
Lines 187
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375137148 news.xs4all.nl 15929 [2001:888:2000:d::a6]:33973
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:51513

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 29 July 2013 22:34, Steven D'Aprano <steve+comp.lang.python@pearwood.info
> wrote:

> On Mon, 29 Jul 2013 15:18:59 -0500, Ed Leafe wrote:
>
> > On Jul 29, 2013, at 3:08 PM, Joel Goldstick <joel.goldstick@gmail.com>
> > wrote:
> >> Not performance, but human readability
> >
> >       IMO, this isn't always the case. There are many lines of code
> that are
> >       broken up to meet the 79 character limit, and as a result become
> much
> >       less readable.
>
> Speaking of readability, what's with the indentation of your post? The
> leading tab plays havoc with my newsreader's word-wrapping.
>
> Breaking lines to fit in 79 characters should almost always be perfectly
> readable, if you break it at natural code units rather than at random
> places. E.g. I have a code snippet that looks like this:
>
> [....whatever...]
> else:
>     completer = completer.Completer(
>                     bindings=(r'"\C-xo": overwrite-mode',
>                               r'"\C-xd": dump-functions',
>                               )
>                             )
>
> I'm not entirely happy with the placement of the closing brackets, but by
> breaking the line at the arguments to Completer, and then putting one
> binding per line, I think it is perfectly readable. And much more
> readable than (say) this:
>
>
> else:
>     completer = completer.Completer(bindings=
>         (r'"\C-xo": overwrite-mode', r'"\C-xd": dump-functions',))
>

But less readable to me than:

    completer = completer.Completer(bindings=[r'"\C-xo": overwrite-mode',
r'"\C-xd": dump-functions'])

Personal preference.

As far as I can tell, that's pretty much the longest line I have in my
> personal code base, possibly excepting unit tests with long lists of
> data. I simply don't write deeply nested classes and functions unless I
> absolutely need to.


I'd go for:

    completer = completer.Completer(bindings=[
  r'"\C-xo": overwrite-mode',
  r'"\C-xd": dump-functions'
    ])

although possibly drop the "bindings=" if possible. "[]" is less ambiguous
a construct than "()"¹ and the "balance" of the code is better my way if
such ephemeral ideas as that count.

Anyway, the point I'm trying to make is that *line length is a personal
thing*. There are two rules:

1) Stick with what other people on the team are doing, if relevant
2) Don't be stupid

The rest is your choice. Some people like 80 character limits, but I've
consistently preferred "whatever you think" as a better rule.

¹ As in there are fewer possible uses, so it's quicker to know what you're
using it for

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: PEP8 79 char max Ed Leafe <ed@leafe.com> - 2013-07-29 15:18 -0500
  Re: PEP8 79 char max Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-29 21:34 +0000
    Re: PEP8 79 char max Joshua Landau <joshua@landau.ws> - 2013-07-29 23:24 +0100

csiph-web