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


Groups > comp.lang.python > #51684

Re: PEP8 79 char max

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'value,': 0.04; 'argument': 0.05; 'arguments': 0.09; 'lines:': 0.09; 'rows': 0.09; 'rows,': 0.09; '-tkc': 0.16; '42,': 0.16; 'adjusted': 0.16; 'collections': 0.16; 'columns': 0.16; 'descriptor': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'given)': 0.16; 'length,': 0.16; 'merely': 0.16; 'namedtuple': 0.16; 'readable': 0.16; 'redundancy': 0.16; 'skipped': 0.16; 'typeerror:': 0.16; 'unexpected': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'import': 0.22; 'interpret': 0.24; 'tend': 0.24; '(or': 0.24; 'header:In-Reply- To:1': 0.27; 'tim': 0.29; '(like': 0.30; 'statement': 0.30; 'code': 0.31; 'easier': 0.31; 'aligned': 0.31; 'chase': 0.31; 'tuples': 0.31; 'maintaining': 0.32; 'table': 0.34; 'editor': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'keyword': 0.36; 'doing': 0.36; 'charset:us-ascii': 0.36; 'to:addr:python-list': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'break': 0.61; 'mentioned': 0.61; 'skip:n 10': 0.64; 'more': 0.64; 'benefit': 0.68; 'dr.': 0.77; 'you:': 0.81; 'dry': 0.84; 'noise': 0.84; 'received:50.22': 0.84; '"how': 0.91; 'aligning': 0.91; 'edwards': 0.91; 'wanting': 0.93
Date Wed, 31 Jul 2013 13:24:59 -0500
From Tim Chase <python.list@tim.thechases.com>
To python-list@python.org
Subject Re: PEP8 79 char max
In-Reply-To <ktbe6u$or0$1@reader1.panix.com>
References <51F6C5F5.5020201@Gmail.com> <CAPM-O+y++Q499zgYBGxTdPhLX9D_CfOwHnRTTo+ncQrPVFpD7g@mail.gmail.com> <mailman.5265.1375129503.3114.python-list@python.org> <51f6e1d8$0$30000$c3e8da3$5496439d@news.astraweb.com> <51F6ED13.5010508@Gmail.com> <EB2D8574-23DC-408F-B87E-A0B84B6DC7FF@leafe.com> <kt8rul$qvv$1@ger.gmane.org> <mailman.5331.1375206170.3114.python-list@python.org> <kt8ugu$jj0$1@reader1.panix.com> <CAN1F8qXS6H3dV6jZSJ_N6NTOQjrKKzy8h5uO3LZAWjsCXPmYKA@mail.gmail.com> <mailman.8.1375268124.1251.python-list@python.org> <ktbe6u$or0$1@reader1.panix.com>
X-Mailer Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
X-Get-Message-Sender-Via boston.accountservergroup.com: none
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.46.1375295014.1251.python-list@python.org> (permalink)
Lines 60
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375295014 news.xs4all.nl 15880 [2001:888:2000:d::a6]:52315
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:51684

Show key headers only | View raw


On 2013-07-31 16:32, Grant Edwards wrote:
> On 2013-07-31, Tim Chase <python.list@tim.thechases.com> wrote:  
> > I interpret Grant's statement as wanting the "table" to look like
> >
> >   for name, value, description in (
> >       ("cost",   42,   "How much it cost"),
> >       ("status", 3141, "Status code from ISO-3.14159"),
> >       ...
> >       ):
> >     do_something(name, value)
> >     print(description)  
> 
> Exactly.  When you have more than about 5 columns and 10 rows,
> having things aligned makes it far, far, easier to maintain.  

As mentioned by Marcelo, when they can vary in length, maintaining is
a pain.  Even if your editor supports aligning (like vim with Dr.
Chip's align.vim plugin).  If I have a table of greater dimensions, I
tend to refactor into a more readable+maintainable scheme, whether
using dicts or named tuples and then break out the rows onto their own
lines:

  from collections import namedtuple
  Descriptor = namedtuple("Descriptor", ["name", "value", "description"])
  for name, value, description in (
      Descriptor(
        name="cost",
        value=42,
        description="How much it cost",
        ),
      Descriptor(
        name="status",
        value=3141,
        description="Status code from ISO-3.14159",
        ),
      ):
    do_something(name, value)
    print(description)

Using a namedtuple, if you forget one of the fields (or add an
extra, or misspell one), it yells at you:

  TypeError: __new__() takes exactly 4 arguments (2 given)
  TypeError: __new__() takes exactly 4 arguments (6 given)
  TypeError: __new__() got an unexpected keyword argument 'nmae'

There is redundancy of the kwarg params, but this can be skipped
if you prefer DRY code to more readable code.

Doing this also has the benefit that, when diffing, you don't get
noise when columns are merely adjusted visually.

-tkc






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


Thread

Re: PEP8 79 char max Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-29 16:24 -0400
  Re: PEP8 79 char max Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-29 21:42 +0000
    Re: PEP8 79 char max Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-07-29 18:30 -0400
    Re: PEP8 79 char max Ed Leafe <ed@leafe.com> - 2013-07-29 17:54 -0500
    Re: PEP8 79 char max Vito De Tullio <vito.detullio@gmail.com> - 2013-07-30 19:08 +0200
    Re: PEP8 79 char max Joshua Landau <joshua@landau.ws> - 2013-07-30 18:42 +0100
      Re: PEP8 79 char max Grant Edwards <invalid@invalid.invalid> - 2013-07-30 17:52 +0000
        Re: PEP8 79 char max Joshua Landau <joshua@landau.ws> - 2013-07-31 07:16 +0100
        Re: PEP8 79 char max Tim Chase <python.list@tim.thechases.com> - 2013-07-31 05:56 -0500
          Re: PEP8 79 char max Neil Cerutti <neilc@norwich.edu> - 2013-07-31 13:02 +0000
            Re: PEP8 79 char max Grant Edwards <invalid@invalid.invalid> - 2013-07-31 16:35 +0000
              Re: PEP8 79 char max Marcelo MD <lists.md@gmail.com> - 2013-07-31 14:45 -0300
                Re: PEP8 79 char max Neil Cerutti <neilc@norwich.edu> - 2013-07-31 17:59 +0000
                Re: PEP8 79 char max Grant Edwards <invalid@invalid.invalid> - 2013-07-31 18:16 +0000
                Re: PEP8 79 char max Neil Cerutti <neilc@norwich.edu> - 2013-07-31 18:37 +0000
                Re: PEP8 79 char max Grant Edwards <invalid@invalid.invalid> - 2013-07-31 18:56 +0000
                Re: PEP8 79 char max Neil Cerutti <neilc@norwich.edu> - 2013-07-31 19:25 +0000
                RE: PEP8 79 char max "Prasad, Ramit" <ramit.prasad@jpmorgan.com.dmarc.invalid> - 2013-07-31 18:33 +0000
              Re: PEP8 79 char max Skip Montanaro <skip@pobox.com> - 2013-07-31 13:05 -0500
          Re: PEP8 79 char max Grant Edwards <invalid@invalid.invalid> - 2013-07-31 16:32 +0000
            Re: PEP8 79 char max Tim Chase <python.list@tim.thechases.com> - 2013-07-31 13:19 -0500
            Re: PEP8 79 char max Tim Chase <python.list@tim.thechases.com> - 2013-07-31 13:24 -0500
            Re: PEP8 79 char max Joshua Landau <joshua@landau.ws> - 2013-08-01 18:21 +0100
              Re: PEP8 79 char max Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-01 19:03 +0000
              Re: PEP8 79 char max Grant Edwards <invalid@invalid.invalid> - 2013-08-01 19:29 +0000
                Re: PEP8 79 char max Grant Edwards <invalid@invalid.invalid> - 2013-08-01 19:53 +0000
                Re: PEP8 79 char max Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-08-01 20:39 -0400
                Re: PEP8 79 char max Grant Edwards <invalid@invalid.invalid> - 2013-08-02 13:58 +0000
        Re: PEP8 79 char max Wayne Werner <wayne@waynewerner.com> - 2013-08-03 06:23 -0500
          Re: PEP8 79 char max Metallicow <metaliobovinus@gmail.com> - 2013-09-05 15:21 -0700
            Re: PEP8 79 char max Terry Reedy <tjreedy@udel.edu> - 2013-09-05 21:47 -0400
              Re: PEP8 79 char max Metallicow <metaliobovinus@gmail.com> - 2013-09-05 19:59 -0700
                Re: PEP8 79 char max Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-06 04:01 +0000
                Re: PEP8 79 char max Metallicow <metaliobovinus@gmail.com> - 2013-09-05 21:21 -0700
                Re: PEP8 79 char max Metallicow <metaliobovinus@gmail.com> - 2013-09-06 06:34 -0700
                Re: PEP8 79 char max Metallicow <metaliobovinus@gmail.com> - 2013-09-06 09:07 -0700
                Re: PEP8 79 char max Skip Montanaro <skip@pobox.com> - 2013-09-06 05:09 -0500
                Re: PEP8 79 char max Tim Chase <python.list@tim.thechases.com> - 2013-09-06 05:35 -0500
                Re: PEP8 79 char max Tim Delaney <timothy.c.delaney@gmail.com> - 2013-09-06 20:47 +1000
                Re: PEP8 79 char max Metallicow <metaliobovinus@gmail.com> - 2013-09-06 05:24 -0700
                Re: PEP8 79 char max Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-09-06 19:22 -0400
                Re: PEP8 79 char max Tim Chase <python.list@tim.thechases.com> - 2013-09-06 07:56 -0500
                Re: PEP8 79 char max Neil Cerutti <neilc@norwich.edu> - 2013-09-06 13:12 +0000
            Re: PEP8 79 char max Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-06 03:40 +0000
              Re: PEP8 79 char max Metallicow <metaliobovinus@gmail.com> - 2013-09-05 21:19 -0700
              Re: PEP8 79 char max Serhiy Storchaka <storchaka@gmail.com> - 2013-09-07 21:00 +0300
    Re: PEP8 79 char max Vito De Tullio <vito.detullio@gmail.com> - 2013-07-30 20:00 +0200

csiph-web