use fileinput to read a specific line

Martin Marcher martin at marcher.name
Tue Jan 8 09:18:33 EST 2008


Fredrik Lundh wrote:

> Martin Marcher wrote:
> 
>>> i need to read line 4 from a header file
>> 
>> http://docs.python.org/lib/module-linecache.html
> 
> I guess you missed the "using linecache will crash my computer due to
> memory loading, because i am working on 2000 files each is 8mb" part.

oops sorry indeed

still the enumerate version seems fine:
>>> for no, line in enumerate(file("data.txt", "r")):
...     print no, line
...

someone posted this already i think (or was it another thread?)

-- 
http://noneisyours.marcher.name
http://feeds.feedburner.com/NoneIsYours

You are not free to read this message,
by doing so, you have violated my licence
and are required to urinate publicly. Thank you.




More information about the Python-list mailing list