[Tutor] Reading opened files

Lisi lisi.reisz at gmail.com
Fri Jun 17 18:20:47 CEST 2011


Hello :-)

I have got as far as I have,i.e. apparently succeeding in both opening and 
closing two different files, thanks to google, but my struggles to _do_ 
something with a file that I have opened are getting me nowhere.  Here is my 
latest failure:

>>> file=open("/home/lisi/CHOOSING_SHOES.txt", "r")
>>> file.close()
>>> file=open("/home/lisi/CHOOSING_SHOES.txt", "r")
>>> whole=file.read
>>> print whole
<built-in method read of file object at 0xb74c48d8>
>>> print "%r" % whole
<built-in method read of file object at 0xb74c48d8>
>>> print "whole is %r" %whole
whole is <built-in method read of file object at 0xb74c48d8>
>>> print "whole is %r" % whole
whole is <built-in method read of file object at 0xb74c48d8>
>>> 

I'd be extremely grateful if one of you was willing to drop a hint, give me 
some pointers (even e.g. guide me to asking the correct question of Google), 
or tell me where I am going wrong.

In general, the author advises leaving any of the extra credit questions that 
you are struggling with and coming back to them later.  And in general I have 
found that that works.  But this set of extra-credit questions he advises 
mastering before moving on.  And I am stuck on this one at this stage. :-(  
(I think that I have cracked the others.)

Thanks.

Lisi


More information about the Tutor mailing list