This is fine for quickly retrieving some data, but does not give you the ability to easily distinguish between normal page retrievals and 404 or 500 errors. The urllib2 module offers a similar function that throws an exception should one of these HTTP errors be encountered:

Using httplib2

If the urllib2 code for making authenticated requests strikes you as over-complicated, you may be interested in Joe Gregorio's httplib2 library. It is not included in the Python standard library so you will need to download and install it separately.

All requests are passed through an instance of the Http class. You can optionally enable an HTTP cache by passing a directory to that constructor; this is not necessary for the Yahoo! APIs as they do not directly support this kind of caching.