<div>Your problem is right here:</div><div><br></div><div>>>> whole=file.read<br>>>> print whole</div><div><br></div><div>Your re-assigning the method "read()", which is a method of the object "file" to the variable "whole"</div>
<div><br></div><div>So, when you print "whole" you can see that it is printing the location of the method in memory. If you were to print file.read you would get the same results.</div><div><br></div><div>Now, to call the method (or a function) you need to add the parentheses with any arguments that it may need. In your case, you need to do "read()".</div>
<div><br></div><div>This principle holds true with any object.</div><div><br></div><div>So, let's say we created a list object by doing this mylist = []</div><div><br></div><div>mylist now has all of the methods that a list has. So, for example, I can append something to the list by going:</div>
<div><br></div><div>mylist.append(1)</div><div><br></div><div>printing my list will show a list like this [1]</div><div><br></div><div><div>IDLE 2.6.5 </div><div>>>> mylist = []</div><div>>>> mylist.append(1)</div>
<div>>>> print mylist</div><div>[1]</div></div><div><br></div><div>but instead lets say I did this:</div><div><br></div><div><div>>>> b = mylist.append</div><div>>>> print b</div><div><built-in method append of list object at 0x0118FD50></div>
</div><div><br></div><div>Which can be handy if i needed to do appending all the time, for example:</div><div><br></div><div><div>>>> b(1)</div><div>>>> print mylist</div><div>[1, 1]</div></div><div><br>
</div><div>My last piece of advice here is, use the Python documentation in addition to googling. It's actually very readable (I think anyway)</div><br><br><div class="gmail_quote">On Fri, Jun 17, 2011 at 12:20 PM, Lisi <span dir="ltr"><<a href="mailto:lisi.reisz@gmail.com">lisi.reisz@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hello :-)<br>
<br>
I have got as far as I have,i.e. apparently succeeding in both opening and<br>
closing two different files, thanks to google, but my struggles to _do_<br>
something with a file that I have opened are getting me nowhere. Here is my<br>
latest failure:<br>
<br>
>>> file=open("/home/lisi/CHOOSING_SHOES.txt", "r")<br>
>>> file.close()<br>
>>> file=open("/home/lisi/CHOOSING_SHOES.txt", "r")<br>
>>> whole=file.read<br>
>>> print whole<br>
<built-in method read of file object at 0xb74c48d8><br>
>>> print "%r" % whole<br>
<built-in method read of file object at 0xb74c48d8><br>
>>> print "whole is %r" %whole<br>
whole is <built-in method read of file object at 0xb74c48d8><br>
>>> print "whole is %r" % whole<br>
whole is <built-in method read of file object at 0xb74c48d8><br>
>>><br>
<br>
I'd be extremely grateful if one of you was willing to drop a hint, give me<br>
some pointers (even e.g. guide me to asking the correct question of Google),<br>
or tell me where I am going wrong.<br>
<br>
In general, the author advises leaving any of the extra credit questions that<br>
you are struggling with and coming back to them later. And in general I have<br>
found that that works. But this set of extra-credit questions he advises<br>
mastering before moving on. And I am stuck on this one at this stage. :-(<br>
(I think that I have cracked the others.)<br>
<br>
Thanks.<br>
<font color="#888888"><br>
Lisi<br>
_______________________________________________<br>
Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</font></blockquote></div><br>