Terry J. Reedy <tjre...@udel.edu> added the comment: On 3.2.2, your example (adapted) produces >>> 2945 characters fetched
So, as Senthil said, the requested feature already exists. But it cannot be added to the 2.7 series; the Python 2.7 *language* is feature frozen. 2.7.z bug fixes serve to make the implementation better match the intended language. Prior to the addition of with..., the standard way to close things was with explicit .close() or implicit closing when the function returned or the program exited. In the 3.2 docs, "20.5.21. Examples", there are several examples with f = <some opener> <do something with f> (closing ignored) Where possible, these could and should be changed in 3.2+ docs to with <some opener> as f: <do something with f> to promote the new idiom. This had been done in other chapters. Perhaps there is also a need for 'X supports the context manager protocol' to be added here or there. But showing that in the examples would make the point. I have changed the title of this issue to match. ---------- components: +Documentation -Library (Lib) stage: test needed -> needs patch title: urllib2.build_opener().open() is not friendly to "with ... as:" -> urllib.request example should use "with ... as:" versions: +Python 3.2 _______________________________________ 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