Non-Indented python

Sandy Norton sandskyfly at hotmail.com
Wed Nov 21 10:31:22 CET 2001


Michael Kelly <mkelly2002 at earthlink.net> wrote 

> Is there a utility to "clean" foreign scripts so that tabs/spaces
> issues and other stuff invisible to the programmer can be
> weeded out?  I mean, it would save a lot of time if I could
> stick some Begin .. Ends or {} delimiters in the script and
> move on to what I'm trying to do or at lease mark a block
> and "clean" it so I'd know there'd be and end point to
> messing with lines that have no apparent syntactic
> errors(and are aligned, at least to the naked eye.)


Here are some doc comments from pindent.py (located in Python\Tools\Scripts):

# This file contains a class and a main program that perform three
# related (though complimentary) formatting operations on Python
# programs.  When called as "pindent -c", it takes a valid Python
# program as input and outputs a version augmented with block-closing
# comments.  When called as "pindent -d", it assumes its input is a
# Python program with block-closing comments and outputs a commentless
# version.   When called as "pindent -r" it assumes its input is a
# Python program with block-closing comments but with its indentation
# messed up, and outputs a properly indented version.


I also use reindent.py (same location as above)... here's what the doc says:
"Change Python (.py) files to use 4-space indents and no hard tab characters.
Also trim excess whitespace from ends of lines, and empty lines at the ends
of files.  Ensure the last line ends with a newline."

Happy Pythoning,

Sandy



More information about the Python-list mailing list