Methods on file-like objects can only used once on one object?
Yingjie Lin
Yingjie.Lin at mssm.edu
Tue Aug 23 10:21:09 EDT 2011
Hi Python users,
I just realize that my post yesterday shouldn't be specifically for mechanize. It should be a general question for file-like objects.
>>> f = open('my_file.txt')
>>> print f.readlines()
( prints a list of strings
>>> print f.readlines()
[]
There are quite a few methods for file-like objects that can only be used once on one object. If I prefer to use some of these methods on one object, one after another, like:
f.readlines()
f.read()
...
What should I do? Thank you.
- Yingjie
More information about the Python-list
mailing list