mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Use universal construct os.path.expanduser('~') instead of os.environ['HOME']
This commit is contained in:
parent
ebbf1e67a8
commit
4dcf50250c
2 changed files with 2 additions and 2 deletions
|
@ -719,7 +719,7 @@ cookies (assumes Unix/Netscape convention for location of the cookies file)::
|
||||||
|
|
||||||
import os, http.cookiejar, urllib.request
|
import os, http.cookiejar, urllib.request
|
||||||
cj = http.cookiejar.MozillaCookieJar()
|
cj = http.cookiejar.MozillaCookieJar()
|
||||||
cj.load(os.path.join(os.environ["HOME"], ".netscape/cookies.txt"))
|
cj.load(os.path.join(os.path.expanduser("~"), ".netscape", "cookies.txt"))
|
||||||
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
|
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
|
||||||
r = opener.open("http://example.com/")
|
r = opener.open("http://example.com/")
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ normally be executed automatically during interactive sessions from the user's
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import readline
|
import readline
|
||||||
histfile = os.path.join(os.environ["HOME"], ".pyhist")
|
histfile = os.path.join(os.path.expanduser("~"), ".pyhist")
|
||||||
try:
|
try:
|
||||||
readline.read_history_file(histfile)
|
readline.read_history_file(histfile)
|
||||||
except IOError:
|
except IOError:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue