Ask your own question, for FREE!
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW) 15 Online
OpenStudy (anonymous):

Python MOOC question In Chapter 11 of (How to Think Like a Computer Scientist) there are some examples given. >>> newtext=open("test2.dat", "r") >>> print newtext.read() Now is the timeto close the file >>> print newtext.read() The second time I use print newtext.read() it gives me no results. I have no Idea why this is, I've stored the contents of the file "test2.dat" in the variable newtext, right? Any ideas?

OpenStudy (rsmith6559):

newtext is a file object. It allows various operations (methods) to be called. The contents of the file haven't been stored. They were printed. My guess is that since you read the file, the file's pointer is pointing to the end of the file (EOF), and the second call has nothing new to read.

OpenStudy (anonymous):

Thank you for your help. :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!