[docs] [issue18914] Python docs link to terrible outsi

Brian Mingus report at bugs.python.org
Tue Sep 3 19:30:20 CEST 2013

New submission from Brian Mingus:

The python documentation links to an outside website for info and examples on http basic auth. This documentation is terrible and confusing. The link should be removed, and user's should be advised to use the Requests library.

# this example is from http://www.voidspace.org.uk/python/articles/authentication.shtml
# which is linked to by the official python docs http://docs.python.org/2/howto/urllib2.html

import urllib2
theurl = 'http://www.someserver.com/toplevelurl/somepage.htm'
username = 'johnny'
password = 'XXXXXX'
# a great password
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
# this creates a password manager
passman.add_password(None, theurl, username, password)
# because we have put None at the start it will always
# use this username/password combination for  urls
# for which `theurl` is a super-url
authhandler = urllib2.HTTPBasicAuthHandler(passman)
# create the AuthHandler
opener = urllib2.build_opener(authhandler)
# All calls to urllib2.urlopen will now use our handler
# Make sure not to include the protocol in with the URL, or
# HTTPPasswordMgrWithDefaultRealm will be very confused.
# You must (of course) use it when fetching the page though.
pagehandle = urllib2.urlopen(theurl)
# authentication is now handled automatically for us

assignee: docs at python
components: Documentation
messages: 196854
nosy: docs at python, mingus
priority: normal
severity: normal
status: open
title: Python docs link to terrible outsi
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the docs mailing list