Fix Python – Line continuation for list comprehensions or generator expressions in python

How are you supposed to break up a very long list comprehension?
[something_that_is_pretty_long for something_that_is_pretty_long in somethings_that_are_pretty_long]

I have also seen somewhere that people that dislike using ‘\’ to break up lines,
but never understood why. What is the reason behind this?

Fix Python – PEP 8, why no spaces around ‘=’ in keyword argument or a default parameter value?

Why does PEP 8 recommend not having spaces around = in a keyword argument or a default parameter value?
Is this inconsistent with recommending spaces around every other occurrence of = in Python code?
How is:
func(1, 2, very_long_variable_name=another_very_long_variable_name)

better than:
func(1, 2, very_long_variable_name = another_very_long_var….

Fix Python – Tool to convert Python code to be PEP8 compliant

I know there are tools which validate whether your Python code is compliant with PEP8, for example there is both an online service and a python module.
However, I cannot find a service or module which can convert my Python file to a self-contained, PEP8 valid Python file. Does anyone know if there are any?
I assume it’s feasible since PEP8 is all….

Fix Python – What’s the correct way to sort Python `import x` and `from x import y` statements?

The python style guide suggests to group imports like this:

Imports should be grouped in the following order:

standard library imports
related third party imports
local application/library specific imports

However, it does not mention anything how the two different ways of imports should be laid out:
from foo import bar
import foo

There are m….

Fix Python – How to write very long string that conforms with PEP8 and prevent E501

As PEP8 suggests keeping below the 80 column rule for your python program, how can I abide to that with long strings, i.e.
s = “this is my really, really, really, really, really, really, really long string that I’d like to shorten.”

How would I go about expanding this to the following line, i.e.
s = “this is my really, really, really, really, rea….