PEP8 79 char max

  • Thread starter Devyn Collier Johnson
  • Start date
D

Devyn Collier Johnson

In Python programming, the PEP8 recommends limiting lines to a maximum
of 79 characters because "There are still many devices around that are
limited to 80 character lines"
(http://www.python.org/dev/peps/pep-0008/#code-lay-out). What devices
cannot handle 80 or more characters on a line? Would following this
recommendation improve script performance?

Mahalo,

Devyn Collier Johnson
(e-mail address removed)
 
J

John Gordon

In said:
(http://www.python.org/dev/peps/pep-0008/#code-lay-out). What devices
cannot handle 80 or more characters on a line?

For a start, older fixed-width dumb terminals and printers. And even some
very new devices (tablet, smartphone) might have limited screen sizes.

And even if you're on a device that can display more than 80 characters, it
can be convenient to have several windows display side-to-side.
Would following this recommendation improve script performance?

No, but it improves human readability.
 
S

Steven D'Aprano

In Python programming, the PEP8 recommends limiting lines to a maximum
of 79 characters because "There are still many devices around that are
limited to 80 character lines"
(http://www.python.org/dev/peps/pep-0008/#code-lay-out). What devices
cannot handle 80 or more characters on a line?

The only one I can think of is actual xterms (Ctrl-Alt-Function key
terminals on Unix and Linux). But I think that's actually a red-herring.
At least for me, I don't care about devices with 80 character lines.
(Smart phones? Or is that more likely to be 40 character lines?)

I care about being able to put multiple windows side-by-side, or a single
window with code in one pane and a class map at the side. I care about
being able to copy and paste code into an email, or Usenet post, without
it being mangled. I care about *never* having to scroll left-to-right in
order to read a line.

And most of all, I care about lines being short enough to read without
eye strain and mental fatigue from excessive horizontal width.

Would following this
recommendation improve script performance?

No, it is irrelevant to performance, except performance of the reader.
 
L

llanitedave

It's not just the number of characters, it's the size and the font. Even fixed-width fonts differ greatly in their readability.

I can handle different line widths just fine up til about 120 or so withoutlosing the flow of the program, but some fonts simply make it more difficult at any width.

I've tried many, but for some reason I keep coming back to Courier10 at 10 points. I'm almost embarrassed that my choice is such an old and primitivefont, but that's how my brain works.

In my experience, if code is well-spaced, well-commented, and broken up into logical groups with appropriate blank spaces, line length can be about 3/4 the width of whatever editor is being used. And most editors are wide enough to easily accommodate over 100 characters.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top