[Python-checkins] cpython (3.1): Use universal construct os.path.expanduser('~') instead of os.environ['HOME']

eric.araujo python-checkins at python.org
Sat Mar 26 02:04:01 CET 2011


http://hg.python.org/cpython/rev/2879c986c5b4
changeset: 68945:2879c986c5b4
branch: 3.1
parent: 68924:ed02db9921ac
user: Éric Araujo <merwok at netwok.org>
date: Fri Mar 25 20:31:50 2011 +0100
summary:
 Use universal construct os.path.expanduser('~') instead of os.environ['HOME']
files:
 Doc/library/http.cookiejar.rst | 2 +-
 Doc/library/readline.rst | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Doc/library/http.cookiejar.rst b/Doc/library/http.cookiejar.rst
--- a/Doc/library/http.cookiejar.rst
+++ b/Doc/library/http.cookiejar.rst
@@ -719,7 +719,7 @@
 
 import os, http.cookiejar, urllib.request
 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))
 r = opener.open("http://example.com/")
 
diff --git a/Doc/library/readline.rst b/Doc/library/readline.rst
--- a/Doc/library/readline.rst
+++ b/Doc/library/readline.rst
@@ -197,7 +197,7 @@
 
 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:
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /