cpython: 8625627969aa (original) (raw)

Mercurial > cpython

changeset 75618:8625627969aa 3.2

closes Issue12365 - Add an example explaining the context manager use case of urllib.urlopen

Senthil Kumaran senthil@uthcode.com
date Tue, 13 Mar 2012 19:47:51 -0700
parents 7bae16233943
children 074e12441ed6 fd4b4650856f
files Doc/library/urllib.request.rst
diffstat 1 files changed, 13 insertions(+), 5 deletions(-)[+] [-] Doc/library/urllib.request.rst 18

line wrap: on

line diff

--- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -46,8 +46,8 @@ The :mod:urllib.request module defines If neither cafile nor capath is specified, an HTTPS request will not do any verification of the server's certificate.

-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. :: +

+It is also possible to achieve the same result without using the +:term:context manager approach. :: >>> import urllib.request >>> f = urllib.request.urlopen('http://www.python.org/')[](#l1.33) @@ -976,7 +985,6 @@ will use same for decoding the bytes obj <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtm[](#l1.36) - In the following example, we are sending a data-stream to the stdin of a CGI and reading the data it returns to us. Note that this example will only work when the Python installation supports SSL. ::