Python Gotcha's?

John Nagle nagle at animats.com
Sun Apr 8 15:05:27 EDT 2012


On 4/8/2012 10:55 AM, Miki Tebeka wrote:
>> 8.  Opening a URL can result in an unexpected prompt on
>> standard input if the URL has authentication.  This can
>> stall servers.
> Can you give an example? I don't think anything in the standard library does that.

    It's in "urllib".  See

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

"When performing basic authentication, a FancyURLopener instance calls 
its prompt_user_passwd() method. The default implementation asks the 
users for the required information on the controlling terminal. A 
subclass may override this method to support more appropriate behavior 
if needed."

A related "gotcha" is knowing that "urllib" sucks and you should use
"urllib2".

				John Nagle



More information about the Python-list mailing list