diff -r f6199284ef3a Doc/library/urllib.request.rst --- a/Doc/library/urllib.request.rst Wed Mar 14 00:40:57 2012 +0100 +++ b/Doc/library/urllib.request.rst Tue Mar 13 20:44:20 2012 -0400 @@ -46,8 +46,8 @@ If neither *cafile* nor *capath* is specified, an HTTPS request will not do any verification of the server's certificate. - This function returns a file-like object with two additional methods from - the :mod:`urllib.response` module + This function returns a file-like object that works as a :term:`context manager`, + with two additional methods from the :mod:`urllib.response` module * :meth:`geturl` --- return the URL of the resource retrieved, commonly used to determine if a redirect was followed @@ -998,8 +998,17 @@ the various ways in which a (X)HTML or a XML document could have specified its encoding information. -As python.org website uses *utf-8* encoding as specified in it's meta tag, we -will use same for decoding the bytes object. :: +As the python.org website uses *utf-8* encoding as specified in it's meta tag, we +will use the same for decoding the bytes object. :: + + >>> with urllib.request.urlopen('http://www.python.org/') as f: + ... print(f.read(100).decode('utf-8')) + ... + >> import urllib.request >>> f = urllib.request.urlopen('http://www.python.org/') @@ -1007,7 +1016,6 @@