Question about the wording in the python documents.

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Fri May 1 21:52:27 EDT 2009


On Fri, 01 May 2009 13:02:59 -0700, grocery_stocker wrote:

> I don't get how urllib2.urlopen() can take a Request object. When I do
> the following....
> 
> [cdalten at localhost ~]$ python
> Python 2.4.3 (#1, Oct  1 2006, 18:00:19) [GCC 4.1.1 20060928 (Red Hat
> 4.1.1-28)] on linux2 Type "help", "copyright", "credits" or "license"
> for more information.
>>>> import urllib2
>>>>
>>>> url = 'http://www.google.com'
>>>> req = urllib2.Request(url)
>>>> response = urllib2.urlopen(req)
>>>>
>>>>
> req is clearly an instance of urllib2.Request and not a Request object.

It looks like a Request object to me. You create it by calling 
urllib2.Request(url), and it's an object.

I don't understand your objection. Is it that the documentation calls it 
Request instead of urllib2.Request? Or that it calls it an object instead 
of an instance? 

In either case, I think you're picking a nit so small that it isn't 
actually there. All objects are instances (in Python), and all instances 
are objects. And it should be clear from context that Request refers to 
urllib2.Request, and not some mythical built-in Request object. I don't 
believe that needs to be spelled out.


-- 
Steven



More information about the Python-list mailing list