Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing documentation in the urllib2 HOWTO #63114

Closed
mingus mannequin opened this issue Sep 3, 2013 · 6 comments
Closed

Confusing documentation in the urllib2 HOWTO #63114

mingus mannequin opened this issue Sep 3, 2013 · 6 comments
Labels
docs Documentation in the Doc dir

Comments

@mingus
Copy link
Mannequin

mingus mannequin commented Sep 3, 2013

BPO 18914
Nosy @orsenthil, @bitdancer, @voidspace

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2013-09-03.22:37:30.838>
created_at = <Date 2013-09-03.17:30:20.756>
labels = ['docs']
title = 'Confusing documentation in the urllib2 HOWTO'
updated_at = <Date 2013-09-03.22:37:30.836>
user = 'https://bugs.python.org/mingus'

bugs.python.org fields:

activity = <Date 2013-09-03.22:37:30.836>
actor = 'michael.foord'
assignee = 'docs@python'
closed = True
closed_date = <Date 2013-09-03.22:37:30.838>
closer = 'michael.foord'
components = ['Documentation']
creation = <Date 2013-09-03.17:30:20.756>
creator = 'mingus'
dependencies = []
files = []
hgrepos = []
issue_num = 18914
keywords = []
message_count = 6.0
messages = ['196854', '196865', '196866', '196867', '196868', '196875']
nosy_count = 5.0
nosy_names = ['orsenthil', 'r.david.murray', 'michael.foord', 'docs@python', 'mingus']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue18914'
versions = ['Python 2.7']

@mingus
Copy link
Mannequin Author

mingus mannequin commented Sep 3, 2013

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)
 
urllib2.install_opener(opener)
# 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

@mingus mingus mannequin assigned docspython Sep 3, 2013
@mingus mingus mannequin added the docs Documentation in the Doc dir label Sep 3, 2013
@ned-deily ned-deily changed the title Python docs link to terrible outsi Confusing documentation in the urllib2 HOWTO Sep 3, 2013
@bitdancer
Copy link
Member

Suggesting using a 3rd party library in order to explain how to use the python standard library to do something isn't going to work.

Would you like to propose an alternate article or an improvement to the howto, using only stdlib facilities?

(Note that the external web page linked to is that of an active Python core contributor.)

@mingus
Copy link
Mannequin Author

mingus mannequin commented Sep 3, 2013

The documentation is confusing. Consider this comment:

# 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.

In the actual code he provides, he uses the protocol. Furthermore, before showing a simple way to use the libary, he shows a godawfully complex way.

Either the documentation should made beautiful and comprehensible, or it should not be linked to.

@bitdancer
Copy link
Member

The article is *explaining* basic auth, thus the pedegogy of the presentation, and why it is a "see also" and not part of the docs proper.

I'll admit I don't understand the first part of that comment, since the second part says you do have to put the protocol in the URL, which is what the example does.

As I said, would you care to propose a replacement?

@mingus
Copy link
Mannequin Author

mingus mannequin commented Sep 3, 2013

Yes - this link was a waste of my time. It would have been better if it had not been there. I propose to replace it with nothing.

@voidspace
Copy link
Contributor

As David explained, the linked article *explains* basic auth as well as showing how to use the standard library support. I think the article is still of some value, it has certainly been useful to many people.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

2 participants