readlines() question

Moshe Zadka moshez at math.huji.ac.il
Fri Jun 9 16:43:03 EDT 2000


On Fri, 9 Jun 2000, Doug Stanfield wrote:

<a very good explanation of file objects, concluding with an example>
> Your example would then have to be:
> 
> my_file = open('file')
> contents = my_file.readlines()
> 
> # Use the file object in any other way you need here.
> 
> my_file.close()

Ummmmm...I'm known as a professional paranoid in many places, so I usually
code like:

my_file = open("blah")
try:
	...my_file.read, my_file.readlines, etc.
finally:
	my_file.close()

--
Moshe Zadka <moshez at math.huji.ac.il>
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com





More information about the Python-list mailing list