Use universal construct os.path.expanduser('~') instead of os.environ['HOME']

This commit is contained in:
Éric Araujo 2011-03-26 01:24:47 +01:00
parent 9aa5a34b6b
commit 8bea9a5b13
2 changed files with 2 additions and 2 deletions

View File

@ -750,7 +750,7 @@ cookies (assumes Unix/Netscape convention for location of the cookies file)::
import os, cookielib, urllib2
cj = cookielib.MozillaCookieJar()
cj.load(os.path.join(os.environ["HOME"], ".netscape/cookies.txt"))
cj.load(os.path.join(os.path.expanduser("~"), ".netscape", "cookies.txt"))
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
r = opener.open("http://example.com/")

View File

@ -211,7 +211,7 @@ normally be executed automatically during interactive sessions from the user's
import os
import readline
histfile = os.path.join(os.environ["HOME"], ".pyhist")
histfile = os.path.join(os.path.expanduser("~"), ".pyhist")
try:
readline.read_history_file(histfile)
except IOError: