Why do I require an "elif" statement here?

John Machin sjmachin at lexicon.net
Fri Aug 4 18:38:03 EDT 2006


sp1d3rx at gmail.com wrote:
> Jim, what you wrote should work correctly. I'm curious as to why you
> are doing it this way though. An easier way would be to take out all
> this character processing and use the builtin string processing.

I'm curious as to why Jim is doing it at all.

Extract from C:\Python24\Tools\Scripts\reindent.py:

'''
# Released to the public domain, by Tim Peters, 03 October 2000.

"""reindent [-d][-r][-v] [ path ... ]

-d (--dryrun)  Dry run.  Analyze, but don't make any changes to, files.
-r (--recurse) Recurse.  Search for all .py files in subdirectories
too.
-v (--verbose) Verbose.  Print informative msgs; else no output.
-h (--help)    Help.     Print this usage information and exit.

Change Python (.py) files to use 4-space indents and no hard tab
characters.
Also trim excess spaces and tabs from ends of lines, and remove empty
lines
at the end of files.  Also ensure the last line ends with a newline.
'''

Cheers,
John




More information about the Python-list mailing list