Re: Pythonic way to overwrite a file

2009-06-18 Thread Tim Wintle
On Wed, 2009-06-17 at 14:26 -0400, Cameron Pulsford wrote: This is only supposed to handle text files, so when would reading it all into memory become too much for most computers? I'm guessing there aren't many source files of too great a size. I often use python with server log files - 1Tb of

Pythonic way to overwrite a file

2009-06-17 Thread Cameron Pulsford
Hey all, hopefully a simple question. I'm writing a simple python tool that opens a file, and does something like for line in file.readlines(): temp.write(line.doStuff()) However, I want to provide the option do this in place, as in have the destination file be the same as the source file.

Re: Pythonic way to overwrite a file

2009-06-17 Thread Ben Charrow
Cameron Pulsford wrote: Hey all, hopefully a simple question. I'm writing a simple python tool that opens a file, and does something like for line in file.readlines(): temp.write(line.doStuff()) However, I want to provide the option do this in place, as in have the destination

Re: Pythonic way to overwrite a file

2009-06-17 Thread Jean-Michel Pichavant
Cameron Pulsford wrote: Hey all, hopefully a simple question. I'm writing a simple python tool that opens a file, and does something like for line in file.readlines(): temp.write(line.doStuff()) However, I want to provide the option do this in place, as in have the destination file be

Re: Pythonic way to overwrite a file

2009-06-17 Thread Cameron Pulsford
Essentially it just cleans up a source file of erroneous spaces and tabs and can also convert tabs to spaces so loading the whole file into memory is possibly an option. I am making this utility for personal use, and that would definitely be fine, but if it turned out well I'd open source it and

Re: Pythonic way to overwrite a file

2009-06-17 Thread Rhodri James
Top-posting, tsk, tsk. On Wed, 17 Jun 2009 19:26:07 +0100, Cameron Pulsford cameron.pulsf...@gmail.com wrote: Essentially it just cleans up a source file of erroneous spaces and tabs and can also convert tabs to spaces so loading the whole file into memory is possibly an option. I am