I am looking for any way to have Emacs format a Python buffer by hitting a few keys. By format, I mean:
- Replace tabs with 4 spaces
- Wrap all long lines correctly at 79 chars. This includes wrapping & concatenating long strings, wrapping long comments, wrapping lists, function headers, etc.
- Unrelated, but when I hit enter, it'd be nice if the cursor was tabbed in automatically.
In general I'd like to just format everything according to PEP 8.
I've looked for a pretty printer / code beautifier / code formatter for Python to run the buffer through, but can't find an open source one.
My .emacs is here.
For those who are going to answer "You don't need a formatter for Python, it's beautiful by the nature of the language," I say to you that this is not correct. In real software systems, comments should be auto-wrapped for you, strings are going to be longer than 79 characters, tab levels run 3+ deep. Please just help me solve my issue directly without some philosophical discussion about the merits of formatting Python source.