On 5/1/2009 1:02 PM grocery_stocker said...
At the following url...

http://docs.python.org/library/urllib2.html

They have the following...

"urllib2.urlopen(url[, data][, timeout])

    Open the URL url, which can be either a string or a Request
object"

I don't get how urllib2.urlopen() can take a Request object. When I do
the following....

[cdal...@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.

Yes -- it seems both the 'Request Object' and 'Request Instance' terms are used.

If you feel it's a bug you can report this at http://bugs.python.org, but I'm not sure what else an object would be if not an instance of a class...

Emile
-----

>>> help (urllib2)
Help on module urllib2:

NAME
    urllib2 - An extensible library for opening URLs
    using a variety of protocols

FILE
    c:\python24\lib\urllib2.py

DESCRIPTION
    The simplest way to use this module is to call the
    urlopen function, which accepts a string containing
    a URL or a Request object (described below).
---------------^^^^^^^^^^^^^^

<snip 2 paragraphs>

    urlopen(url, data=None) -- basic usage is that same
    as original urllib.  pass the url and optionally data
    to post to an HTTP URL, and get a file-like object
    back.  One difference is that you can also pass a
    Request instance instead of URL.
----^^^^^^^^^^^^^^^^


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to