
Raymond Hettinger wrote:
[Lie Ryan]
This is how I will write program if we have 160 character limit:
def foo(f, a, b, c): return [[((f(x, y) * i, i) if i % 2 else 0) for i, x in enumerate(a) if f(y, x) == a + x] for y in [c(z) for z in range(a, a * b + c, c)]]
except there will be no line breaks...
I love list comprehension so much that I often _unconsciously_ write a very complex list comprehensions. 80-character convention acts as a reminder to consider refactoring.
that makes sense to because your example starts close to the left margin. What I'm more concerned about is lines that start many tabs deep. Those become awkward, causing you to wrap them differently than if they were not tabbed. So, I think the 80 char limit should be relaxed only when there is a bunch of whitespace to the left. Your cues for refactoring and coding style should not depend on the initial level of indentation.
On contrary, if the left margin causes me to struggle to keep lines below 80-char, it is an indication that the whole class/function could benefit from refactoring. It is rarely necessary to need more than 2 levels of initial (function level) indentation or 3 if you used closure: e.g.: class def def (closure) and any function that have more than another 2-3 level is an indication that it needs refactoring. class def with for if So in total, 3-5 levels are the maximum in any sane code. To me, 3-5 level is not that deep for 80-char to become a hindrance. Anyway, it seems people keep forgetting that PEP 8 is a guideline, not a syntax. I usually keep lines below 80, but I don't mind breaking them now and then if I think it is justified.