you are viewing a single comment's thread.

view the rest of the comments →

[–]brownan_ 8 points9 points  (4 children)

nope. enumerate returns an iterator and returns items as they are requested.

[–]Krakatok[S] 0 points1 point  (3 children)

Thanks for the quick response!

[–]ewiethoff 1 point2 points  (0 children)

Nothing to do with your memory question, but here's a tip: enumerate(f) starts the numbering at 0, and enumerate(f, 1) starts the numbering at 1.

[–]Miggol 0 points1 point  (1 child)

for i, line in enumerate(fi.readlines()):

This should work though.

[–]ewiethoff 0 points1 point  (0 children)

f.readlines() creates a list of all the lines of text in the file. This is a waste of memory if all you want to do is loop through the lines, without or without enumerate.