Editing files
Steve Holden
sholden at holdenweb.com
Thu Dec 21 08:42:04 EST 2000
dv <lars at stea.nu> wrote in message
news:Bdd06.5591$K6.674078 at juliett.dax.net...
> I'm trying to automate some configuration tasks with python. Is it
possible
> to do a "search and replace" or specify where (which line) in a file
python
> will write?
>
> Thanks in advance
>
> Lars
>
Sounds like you want to update files in place rather than read the old one,
write a new one and replace the old one with it. Am I right?
It's certainly possible to use the tell() and seek() file primitives to find
out where you are in a file and direct output to a particular location in
that file, if that's what you want.
The documentation should give you the rest of the story. For Python 2.0 see
section 2.1.7.9 - File Objects. Hope this helps.
regards
Steve
More information about the Python-list
mailing list