Message144146
Terry, Senthil, thanks, for replying to this ticket. OK, to the question:
1. @Terry, here is the full example as for CPython 2.7 I am talking about and the output:
#################
from urllib2 import Request, build_opener
request = Request('http://example.com')
with build_opener().open(request) as f:
txt = f.read()
print '%d characters fetched' % len(txt)
####################
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: addinfourl instance has no attribute '__exit__'
2. @Senthil, regarding the statement being a feature. I assume, that to open a connection, to read from a connection and to close it -- are the fundamental functions for what urllib2 was in particular created for. I was looking in docs for some hints of "canonical" way of doing this using urllib2.opener. After I have failed to find any guidance in docs, I've created this ticket. That is, I assume that no new feature is needed, but just a documented 5-lines example about a typical way of doing the above operations, especially *closing* the connection.
regards,
Valery |
|
Date |
User |
Action |
Args |
2011-09-16 18:15:26 | Valery.Khamenya | set | recipients:
+ Valery.Khamenya, terry.reedy, orsenthil, ezio.melotti, docs@python |
2011-09-16 18:15:26 | Valery.Khamenya | set | messageid: <1316196926.85.0.549257838458.issue12955@psf.upfronthosting.co.za> |
2011-09-16 18:15:26 | Valery.Khamenya | link | issue12955 messages |
2011-09-16 18:15:25 | Valery.Khamenya | create | |
|