PEP8 79 char max

Tim Chase python.list at
Wed Jul 31 20:19:15 CEST 2013

On 2013-07-31 16:32, Grant Edwards wrote:
> On 2013-07-31, Tim Chase <python.list at> 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

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

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.


More information about the Python-list mailing list