How do I follow python PEP8 regarding line breaks, and how important is it?

Til Hund picture Til Hund · Jan 19, 2016 · Viewed 8k times · Source

I am writing in python 3.5.1 and I am a programming novice.

I use gedit with a pep8 and pyflakes plugins showing style mistakes according to the python style guide. I do not know whether to follow the style recommendation to the letter or not.

I have, however, three recurring style flaws indicated by E501: line too long (80 > 79 characters), E502: the backslash is redundant between brackets and E128/E127/...: continuation line under-indented for visual indent. Screenshots below.

My two questions are:

  1. How can I adequately make a line break in python in order to avoid E501 and the subsequent style errors E502 and E127/128?
  2. Is it helpful to follow the style guide pep8 to the letter, especially with publication in mind? What do advanced python programmers say?

E501: enter image description here

E502: enter image description here

E127/128...: enter image description here

Answer

msw picture msw · Jan 19, 2016

"How can I adequately make a line break in python in order to avoid E501 and the subsequent style errors E502 and E127/128?"

progress = Utils.ProgressMeter('Source strings separated by white '
    'space are automatically concatenated by the '
    'interpreter and parenthesis are the natural syntax '
    'for line continuation. Remember to use trailing '
    'spaces.')

Since error E502 is already inside parentheses, the backslash is redundant. Did you try eliminating it?