steve+comp.lang.pyt...@pearwood.info wrote:
> I have a script running under Python 2.5 that needs to modify files in
> place. I want to do this with some level of assurance that I won't lose
> data. E.g. this is not safe:
> [snip]
Thanks to all who replied, your comments were helpful.
--
Stev
In article <4e0b6383$0$29996$c3e8da3$54964...@news.astraweb.com>
wrote:
>I have a script running under Python 2.5 that needs to modify files in
>place. I want to do this with some level of assurance that I won't lose
>data. ... I have come up with this approach:
[create temp file in suitable dir
On 2011-06-29, steve+comp.lang.pyt...@pearwood.info
wrote:
> I have a script running under Python 2.5 that needs to modify files in
> place. I want to do this with some level of assurance that I won't lose
> data. E.g. this is not safe:
>
> def unsafe_modify(filename):
> fp = open(filename, '
I have a script running under Python 2.5 that needs to modify files in
place. I want to do this with some level of assurance that I won't lose
data. E.g. this is not safe:
def unsafe_modify(filename):
fp = open(filename, 'r')
data = modify(fp.read())
fp.close()
fp = open(filename,
On Mon, 05 Nov 2007 01:55:50 +1100, tech user wrote:
> I have a file which is large about 3.5G.
> I need to modify some lines in it,but I don't like to create another file
> for the result.
> How can i do it? thanks.
In general not a good idea unless the modification does not change the
length of
Hello,
I have a file which is large about 3.5G.
I need to modify some lines in it,but I don't like to create another file
for the result.
How can i do it? thanks.
National Bingo Night. Play along for the chance to win $10,000 every week.
Download your gamecard now at Yahoo!7 TV.
http
There is a module in the library called fileinput, should do what
you're looking for.
--
http://mail.python.org/mailman/listinfo/python-list
Elby wrote:
> I'm looking for a the most simple and generic way to modify a file, with the
> possibility of making backups. In fact, I would like to emulate Perl's -i
> option.
>
> here is a bit of code, to explain it further :
>
> < code >
I'm looking for a the most simple and generic way to modify a file, with the
possibility of making backups. In fact, I would like to emulate Perl's -i
option.
here is a bit of code, to explain it further :
< code >
from os import rename
class Modif_File:
def __init_