[From nobody Thu Jun 29 10:35:10 2006
Return-Path: &lt;koning@pobox.com&gt;
Delivered-To: ipython-user@scipy.net
Received: from localhost (localhost [127.0.0.1])
	by www.scipy.com (Postfix) with ESMTP id 5FBC33EB4F
	for &lt;ipython-user@scipy.net&gt;; Mon, 18 Jul 2005 12:49:08 -0500 (CDT)
Received: from www.scipy.com ([127.0.0.1])
	by localhost (scipy.org [127.0.0.1]) (amavisd-new,
	port 10024) with ESMTP id 27687-03 for &lt;ipython-user@scipy.net&gt;;
	Mon, 18 Jul 2005 12:49:06 -0500 (CDT)
Received: from smtp-2.llnl.gov (smtp-2.llnl.gov [128.115.250.82])
	by www.scipy.com (Postfix) with ESMTP id 4BB883EB3E
	for &lt;ipython-user@scipy.net&gt;; Mon, 18 Jul 2005 12:49:06 -0500 (CDT)
Received: from [128.115.134.58] (localhost [127.0.0.1])
	with ESMTP id j6IIn7O1029976
	for &lt;ipython-user@scipy.net&gt;; Mon, 18 Jul 2005 11:49:07 -0700 (PDT)
Message-ID: &lt;42DBF9A3.5050604@pobox.com&gt;
Date: Mon, 18 Jul 2005 11:49:07 -0700
From: &quot;Joseph M. Koning&quot; &lt;koning@pobox.com&gt;
User-Agent: Mozilla Thunderbird  (X11/20050322)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Cc: IPython-user List &lt;ipython-user@scipy.net&gt;
Subject: Re: [Fwd] Re: [IPython-user] Re[2]: IPython install under Win2000
References: &lt;42DBD43D.9090207@colorado.edu&gt;
	&lt;Mahogany-0.66.0-1424-20050718-140950.00@american.edu&gt;
	&lt;42DBF340.5000700@colorado.edu&gt;
In-Reply-To: &lt;42DBF340.5000700@colorado.edu&gt;
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: by amavisd-new at scipy.org
X-Spambayes-Classification: ham; 0.00
X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on scipy.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,MISSING_HEADERS 
	autolearn=ham version=3.0.3

There was a python thread on cross platform home directory determination 
listed in one of the Python URL's. It discusses the Windows 2000 issue. 
Here is the code:

def getHomeDir():
    ''' Try to find user's home directory, otherwise return current directory.'''
    try:
        path1=os.path.expanduser(&quot;~&quot;)
    except:
        path1=&quot;&quot;
    try:
        path2=os.environ[&quot;HOME&quot;]
    except:
        path2=&quot;&quot;
    try:
        path3=os.environ[&quot;USERPROFILE&quot;]
    except:
        path3=&quot;&quot;

    if not os.path.exists(path1):
        if not os.path.exists(path2):
            if not os.path.exists(path3):
                return os.getcwd()
            else: return path3
        else: return path2
    else: return path1



Here is the thread link:
http://mail.python.org/pipermail/python-list/2005-February/263921.html

Hope this helps,
Joe
Fernando Perez wrote:

&gt; Alan G Isaac wrote:
&gt;
&gt;&gt; On Mon, 18 Jul 2005, Fernando Perez apparently wrote:
&gt;&gt;
&gt;&gt;&gt; In WinXP Home and Pro there is a USERPROFILE and a HOMEPATH (which 
&gt;&gt;&gt; is used as a starting directory when running cmd.exe), but no HOME. 
&gt;&gt;&gt; So any HOME environment variable was added by customizing or by 
&gt;&gt;&gt; another application. 
&gt;&gt;
&gt;&gt;
&gt;&gt;
&gt;&gt; So in Win2000 and WinXP, in any case, relying on
&gt;&gt; USERPROFILE will work better than relying on HOME.
&gt;
&gt;
&gt; Well, for NT if $HOME is undefined, I use this:
&gt;
&gt;             try:
&gt;                 return 
&gt; os.path.join(os.environ['HOMEDRIVE'],os.environ['HOMEPATH'])
&gt;             except:
&gt;                 try:
&gt;                     # Use the registry to get the 'My Documents' folder.
&gt;                     import _winreg as wreg
&gt;                     key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
&gt;
&gt; &quot;Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders&quot;)
&gt;                     homedir = wreg.QueryValueEx(key,'Personal')[0]
&gt;                     key.Close()
&gt;                     return homedir
&gt;                 except:
&gt;                     return 'C:\\'
&gt;
&gt; That's from something I read long ago that said that 
&gt; HOMEDRIVE/HOMEPATH was the proper default location.  Is USERPROFILE 
&gt; the right one instead?  I think I read that at some microsoft page, 
&gt; but I could be wrong.
&gt;
&gt; Cheers,
&gt;
&gt; f
&gt;
&gt; &lt;rant&gt;
&gt; ps - and some people still ask me why I hate windows with an 
&gt; unmitigated passion...  the platform where the phrase 'where do you 
&gt; want to go today' invariably means 'in circles', even for the 
&gt; simplest, seemingly most trivial of tasks.
&gt; &lt;/rant&gt;
&gt;
&gt; _______________________________________________
&gt; IPython-user mailing list
&gt; IPython-user@scipy.net
&gt; http://scipy.net/mailman/listinfo/ipython-user



]