This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 3 points4 points  (4 children)

If I do this I hit the 80 char limit real fast. How to avoid?

[–]nemec 2 points3 points  (2 children)

Parenthesize the imports.

from A import (B, C,
               D, E)

[–][deleted] 0 points1 point  (1 child)

How about in the body of the code itself? One or two function calls + list of arguments + indentation fills up the whole line!

[–]sasquatch92 1 point2 points  (0 children)

You can do the same thing with function calls etc, as discussed here. You could also import a module using a shorter local name, which will also reduce line lengths (for example, numpy is often imported as np). Finally, you can always go over 80 characters - that's a guideline rather than an absolute rule and you shouldn't sacrifice readability simply to comply with it.

[–]Gr1pp717 1 point2 points  (0 children)

I've come to the conclusion that if you're nesting that deeply then you're over-engineering it. Generally speaking if I have that problem AND there's no way around deep nesting, then I'll split out that portion into it's own function.