urllib2 does not implement "with" Python 2.6

John Nagle nagle at animats.com
Thu Aug 12 07:34:36 CEST 2010

   Somewhat to my surprise, in Python 2.6,

	with urllib2.urlopen(url) as fh :

doesn't work.  It fails with
"AttributeError: addinfourl instance has no attribute '__exit__'".

I thought that all the file-like objects supported "with" in 2.6.

				John Nagle

More information about the Python-list mailing list