urllib (and urllib2) read all data from page on open()?

Jeff Shannon jeffshannon at gmail.com
Mon Mar 14 19:50:30 EST 2005


Alex Stapleton wrote:

> Whilst it might be able to do what I want I feel this to be a flaw in urllib
> that should be fixed, or at least added to a buglist somewhere so I can at
> least pretend someone other than me cares.

I'm not sure about this being a flaw.  The point of urllib and urllib2 
is to provide a high-level interface.  At that higher level, one 
shouldn't care whether the data is coming directly from the socket or 
from a buffer.  (And even if it's read directly from the socket, it's 
probably *still* coming from a buffer, it's just that the buffer is in 
the system network code instead of the application code.)

If you need to care about when the network access happens, then you 
should be using the lower-level protocols -- httplib and/or socket.

Jeff Shannon




More information about the Python-list mailing list