Methods on file-like objects can only used once on one object?

Yingjie Lin Yingjie.Lin at
Tue Aug 23 16:21:09 CEST 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:


What should I do? Thank you.

- Yingjie

More information about the Python-list mailing list