Re-open files in Python?
file, python
Solution
You can reset the file pointer by calling `seek()`:
file.seek(0)
will do it. You need that line after your first `readlines()`. Note that `file` has to support random access for the above to work.
Problem
Say I have this simple python script: ``` file = open('C:\\some_text.txt') print file.readlines() print file.readlines() ``` When it is run, the first print prints a list containing the text of the file, while the second print prints a blank list. Not completely unexpected I guess. But is there a way to 'wind back' the file so that I can read it again? Or is the fastest way just to re-open it?