Valery Khamenya <khame...@gmail.com> added the comment:

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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12955>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to