Re: urllib2 does not implement "with" Python 2.6

2010-08-12 Thread Terry Reedy
On 8/12/2010 1:34 AM, John Nagle wrote: 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. No? This seems

Re: urllib2 does not implement "with" Python 2.6

2010-08-11 Thread Paul Rubin
John Nagle writes: > "AttributeError: addinfourl instance has no attribute '__exit__'". > > I thought that all the file-like objects supported "with" in 2.6. > No? I guess not. Use contextlib.closing. -- http://mail.python.org/mailman/listinfo/python-list