How to write to tempfile, remove whitespace, and copy to source ..?
Fredrik Lundh
fredrik at effbot.org
Sun Jan 21 12:51:24 EST 2001
Randolph MacKenzie wrote:
> I want a module that will remove the extra whitespace from all text files in
> a target directory.
> I want to use the tempfile command (on a Windoze2000 box).
you probably want the "inplace" flag to fileinput.input
instead:
Optional in-place filtering: if the keyword argument
inplace=1 is passed to input() or to the FileInput
constructor, the file is moved to a backup file and
standard output is directed to the input file. This
makes it possible to write a filter that rewrites its
input file in place.
http://www.python.org/doc/current/lib/module-fileinput.html
Cheers /F
More information about the Python-list
mailing list