Skip to content

Commit 3825537

Browse files
authored
use f as the as variable
Other examples use `f` as the response variable.
1 parent e56cc3e commit 3825537

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Doc/library/urllib.request.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,8 +1297,8 @@ Use of Basic HTTP Authentication::
12971297
opener = urllib.request.build_opener(auth_handler)
12981298
# ...and install it globally so it can be used with urlopen.
12991299
urllib.request.install_opener(opener)
1300-
with urllib.request.urlopen('http://www.example.com/login.html') as r:
1301-
print(r.read().decode('utf-8'))
1300+
with urllib.request.urlopen('http://www.example.com/login.html') as f:
1301+
print(f.read().decode('utf-8'))
13021302

13031303
:func:`build_opener` provides many handlers by default, including a
13041304
:class:`ProxyHandler`. By default, :class:`ProxyHandler` uses the environment
@@ -1316,8 +1316,8 @@ programmatically supplied proxy URLs, and adds proxy authorization support with
13161316

13171317
opener = urllib.request.build_opener(proxy_handler, proxy_auth_handler)
13181318
# This time, rather than install the OpenerDirector, we use it directly:
1319-
with opener.open('http://www.example.com/login.html') as response:
1320-
print(response.read().decode('utf-8'))
1319+
with opener.open('http://www.example.com/login.html') as f:
1320+
print(f.read().decode('utf-8'))
13211321

13221322
Adding HTTP headers:
13231323

@@ -1328,8 +1328,8 @@ Use the *headers* argument to the :class:`Request` constructor, or::
13281328
req.add_header('Referer', 'http://www.python.org/')
13291329
# Customize the default User-Agent header value:
13301330
req.add_header('User-Agent', 'urllib-example/0.1 (Contact: . . .)')
1331-
with urllib.request.urlopen(req) as r:
1332-
print(r.read().decode('utf-8'))
1331+
with urllib.request.urlopen(req) as f:
1332+
print(f.read().decode('utf-8'))
13331333

13341334

13351335
:class:`OpenerDirector` automatically adds a :mailheader:`User-Agent` header to
@@ -1338,8 +1338,8 @@ every :class:`Request`. To change this::
13381338
import urllib.request
13391339
opener = urllib.request.build_opener()
13401340
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
1341-
with opener.open('http://www.example.com/') as response:
1342-
print(response.read().decode('utf-8'))
1341+
with opener.open('http://www.example.com/') as f:
1342+
print(f.read().decode('utf-8'))
13431343

13441344
Also, remember that a few standard headers (:mailheader:`Content-Length`,
13451345
:mailheader:`Content-Type` and :mailheader:`Host`)

0 commit comments

Comments
 (0)