It can be done with autopep8, but tweaking it so that it does n not ugly things.
For example, I tried autopep8 with its default settings and observed that:
foo = bar - 1 # long comment that goes over col=79....
gets transformed into:
foo = bar - \ 1 # long comment that goes over col=79....
and I would prefer something like:
foo = bar - 1 # here I write a very long # comment that goes # over col=79....
Well,
In fact you should avoid using inline comments:
http://www.python.org/dev/peps/pep-0008/#id22
It would be nice if instead autopep8 could transform all inline comments into a dedicated block comment above the code line
Last edit: Tiago Coutinho 2014-02-05
What it says is you use them sparingly (do not use them to state obvious things).
I think they are justified in the following situations:
Unfortunately these cases are precisely the ones that tend to be long comments.
That said, I totally agree with Tiago that it would be nice if we find a way of converting those to comment blocks above the line