views:

366

answers:

3

Is there an online or offline utility that will format/pretty-print Python source code?

+2  A: 

Depends of what you mean by "format/pretty-print Python source code".

There's Pygments that do syntax highlighting and you can try it online at Lodgeit (it's a pastebin).

There's also the pprint module in the standard library that pretty-print python data sctructures (dict, list, etc.).

If you need help to format you own python code you can use some text editors that have tools to do that, like PyDev/Eclipse.

Etienne
+2  A: 

http://pypi.python.org/pypi/PythonTidy is an excellent, simple script.

I've found that PyLint and other code analysis tools all choke on pyrex, twisted and other modules.

If you want formatting, just use PythonTidy.

Will