<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="IncrediMail 1.0" name=GENERATOR></HEAD>
<BODY style="BACKGROUND-POSITION: 0px 0px; FONT-SIZE: 12pt; MARGIN: 5px 10px 10px; FONT-FAMILY: Arial" bgColor=#ffffff background="" scroll=yes ORGYPOS="0">
<TABLE id=INCREDIMAINTABLE cellSpacing=0 cellPadding=2 width="100%" border=0>
<TBODY>
<TR>
<TD id=INCREDITEXTREGION style="FONT-SIZE: 12pt; CURSOR: auto; FONT-FAMILY: Arial" width="100%">
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV id=receivestrings>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>From:</B></I> <A href="mailto:alan.gauld@freenet.co.uk">Alan Gauld</A></DIV>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>Date:</B></I> 03/23/06 11:34:33</DIV>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>To:</B></I> <A href="mailto:kermit@polaris.net">Kermit Rose</A>; <A href="mailto:dyoo@hkn.eecs.berkeley.edu">Danny Yoo</A></DIV>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>Cc:</B></I> <A href="mailto:tutor@python.org">tutor@python.org</A></DIV>
<DIV dir=ltr style="FONT-SIZE: 11pt"><I><B>Subject:</B></I> Re: [Tutor] urlopen: where are the results?</DIV></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Did you look at the url2lib documentation?</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>****</DIV>
<DIV>&nbsp;</DIV>
<DIV>I thought I had,&nbsp; but I did not see the examples.</DIV>
<DIV>&nbsp;</DIV>
<DIV>I did not know enough to make sense of the documentation.</DIV>
<DIV>&nbsp;</DIV>
<DIV>So I thought that I would just try&nbsp;running the urlopen&nbsp;and see what happened.</DIV>
<DIV>&nbsp;</DIV>
<DIV>*****</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&gt;&gt;&gt; import urllib2</DIV>
<DIV>&gt;&gt;&gt; f = urllib2.urlopen('<A href="http://www.python.org/">http://www.python.org/</A>')</DIV>
<DIV>&gt;&gt;&gt; print f.read(100)</DIV>
<DIV>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;</DIV>
<DIV>&lt;?xml-stylesheet href="./css/ht2html</DIV>
<DIV>========================</DIV>
<DIV>&nbsp;</DIV>
<DIV>Which shows how to open and read a web page.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>******</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanks.&nbsp;&nbsp; I've experimented with the code you've shown me.&nbsp;&nbsp; I feel comfortable with it now.</DIV>
<DIV>&nbsp;</DIV>
<DIV>******</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>And if you went to the index and click 'f' you will find a link</DIV>
<DIV>to 'file object' which gives you the list of methods you can call</DIV>
<DIV>on file objects. (Admittedly not all of them work on file-like</DIV>
<DIV>objects, but most will)</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>**********</DIV>
<DIV>&nbsp;</DIV>
<DIV>How do I get to the index??</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>*****</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>I admit learning how to use the Python document set is not intuitive</DIV>
<DIV>but it's worth persevering and the Module Index is invaluable.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>*****</DIV>
<DIV>&nbsp;</DIV>
<DIV>Eventually I will become expert.&nbsp;&nbsp;&nbsp; Thanks for your help.</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Kermit&nbsp;&nbsp; &lt;&nbsp;&nbsp; <A href="mailto:kermit@polaris.net">kermit@polaris.net</A>&nbsp; &gt;&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>*****</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; Alan G</DIV>
<DIV>Author of the learn to program web tutor</DIV>
<DIV><A href="http://www.freenetpages.co.uk/hp/alan.gauld">http://www.freenetpages.co.uk/hp/alan.gauld</A></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV></TD></TR>
<TR>
<TD id=INCREDIFOOTER width="100%">
<TABLE cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
<TR>
<TD width="100%"></TD>
<TD id=INCREDISOUND vAlign=bottom align=middle></TD>
<TD id=INCREDIANIM vAlign=bottom align=middle></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></BODY></HTML>