More Pythonic?

Aahz Maruch aahz at netcom.com
Tue Sep 14 19:51:42 EDT 1999


In article <14302.34633.583713.527695 at bitdiddle.cnri.reston.va.us>,
Jeremy Hylton  <jeremy at cnri.reston.va.us> wrote:
>
>The way I dealt with this problem in my urllib replacement (see
>http://the-tech.mit.edu/~jeremy/python/urllib2.py) was to raise an
>exception where the exception instance is actually a valid HTTP
>response object.  
>
>A typical usage would be something like this:
>
>try:
>    resp = urllib2.urlopen('http://frob.nitz/')
>except HTTPError:
>    print resp.code, resp.msg

Aside from the obvious glitch that you need to use urllib2.HTTPError,
your code generates a NameError on resp.  I think I know how to fix it,
but I'd like you to tell me in case I miss something obvious.

Overall, your code looks similar to the code I was planning to write,
but the big feature your code is missing is the stack of redirects.
--
                      --- Aahz (@netcom.com)

Androgynous poly kinky vanilla queer het    <*>      http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6  (if you want to know, do some research)




More information about the Python-list mailing list