[Tutor] Problem When Iterating Over Large Test Files

Alan Gauld alan.gauld at btinternet.com
Thu Jul 19 09:53:15 CEST 2012


On 19/07/12 07:00, Steven D'Aprano wrote:

> def four_lines(file_object):
<snipping>....
>              line1 = next(file_object).strip()
>              # Get the next three lines, padding if needed.
>              line2 = next(file_object, '').strip()
>              line3 = next(file_object, '').strip()
>              line4 = next(file_object, '').strip()
>              yield (line1, line2, line3, line4)
<snipping>...

>          for reads, lines in four_lines( INFILE ):
>                  ID_Line_1, Seq_Line, ID_Line_2, Quality_Line = lines

Shouldn't that be

           for reads, lines in enumerate( four_lines(INFILE) ):
                   ID_Line_1, Seq_Line, ID_Line_2, Quality_Line = lines

?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/





More information about the Tutor mailing list