Editing files

D-Man dsh8290 at rit.edu
Thu Dec 21 08:50:32 EST 2000


You probably want to use seek() and tell().  tell will return the
current location in a file and seek will go to a particular location
(it's argument is the same format as the return value of tell).

I have never had a use for them myself so I don't know if there are
any issues such as overrunning the bounds of what you are replacing.
(ie if the new text is longer than the old)

-D

On Thu, Dec 21, 2000 at 01:41:53AM +0000, dv wrote:
> 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
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list