PEP8 79 char max

Joshua Landau joshua at landau.ws
Thu Aug 1 13:21:32 EDT 2013


On 31 July 2013 17:32, Grant Edwards <invalid at invalid.invalid> wrote:

> On 2013-07-31, Tim Chase <python.list at tim.thechases.com> wrote:
> > On 2013-07-31 07:16, Joshua Landau wrote:
> >> On 30 July 2013 18:52, Grant Edwards wrote:
> >>> I also find intializers for tables of data to be much more easily
> >>> read and maintained if the columns can be aligned.
> >>
> >> Why do you have tables in your Python code?
>
> For example: if you're writing an assembler, you usually have a table
> of mnemonics/opcodes/instruction-format/addressing-modes.


Why are you writing an assembler?


>  > I've had occasion to write things 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)
> >
> > 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.


Honestly I've never had to do something like this. If it got that large,
though, I'd factor it out into it's own file and possibly take the advice
from others on this list by making it a CSV.

That said for someone like me the very tiny frequency I'd have to do such a
thing would pale in comparison to the other costs and benefits of variable
with fonts.


>  > which does give some modest readability benefits, but at a creation
> > cost I personally am unwilling to pay.
>
> It only gets typed once, it gets read hundreds or thousands of times.
> Optimize the common case.
>

PEP 8, under the things-not-to-do section, says:

    · More than one space around an assignment (or other) operator to align
it with another.

    Yes:
        x = 1
        y = 2
        long_variable = 3

    No:
        x             = 1
        y             = 2
        long_variable = 3

I assume similar applies here. Obviously PEP 8 isn't a rule but it's a
rough stab at general consensus.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130801/2a84496b/attachment.html>


More information about the Python-list mailing list