I\'m writing a script that logs errors from another program and restarts the program where it left off when it encounters an error. For whatever reasons, the developers of t
Use for and enumerate.
for
Example:
for line_num, line in enumerate(file): if line_num < cut_off: print line
NOTE: This assumes you are already cleaning up your file handles, etc.
Also, the takewhile function could prove useful if you prefer a more functional flavor.