how to format a python source file with tools?

Falcolas garrickp at gmail.com
Mon Nov 30 12:30:30 EST 2009


On Nov 30, 7:37 am, gil_johnson <x7-g5W... at earthlink.net> wrote:
> On Nov 27, 9:58 am, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> [...]
>
> > > so i would like to have a tool to intelligently format the code for me
> > > and make the code more beautiful
> > > and automated.
>
> > This is not possible. Consider the following situation:
> > [...]
> > Both are semantically radically different, and only you know which one
> > is the right one.
> > Diez
>
> I have to agree with Diez, there is no way to automate this. Some
> human intervention is needed. What I would like is an editor that will
> indicate what Python will consider a logical block (and sub-block, and
> sub-sub-block, etc.)
> It's complicated. I've tried to think of a way to do it, and have
> gotten lost after a few changes of indentation.
> Does anyone know of such a thing?
> I miss curly braces with an editor that will highlight matching
> parentheses, braces, etc.
> Gil

At least with Windows, you get a number of scripts included in your
Python install - under the python directory/tools/scripts. There are
several scripts here which are intended to help with indentation
issues - such as reindent and pindent. Those might help you out some.

Nonetheless, it would be better to implement coding standards that
everyone can stick to.



More information about the Python-list mailing list