[Tutor] Can i define anywhere on file object function for reading arange of lines?

Alan Gauld alan.gauld at freenet.co.uk
Sun Dec 5 20:37:38 CET 2004

> Is there any function where I can specify to python
> buit-in function to select specific line (such as
> starting from segment: page 22 TO the next new line)
> instead of the whole lines until EOF. 
> e.g.:
> a = readlines (From , TO )

Not quite, but you can do:


With the disadvantage that the whoile file gets read 
into RAM before the slicing takes place - but then it 
gets garbage collected again pretty well immediately...


Alan G.

More information about the Tutor mailing list