Hi
You <A> wrote on Monday (7/18/2005 at 7:36 PM) thus about [IPython-user]: IPython install under Win2000:
A> On Mon, 18 Jul 2005, Fernando Perez apparently wrote:
>> Unless someone complains soon, this will go into SVN later today
A> Well my only "complaint" is that you do not start by trying
A> os.path.expanduser("~")
A> which I took from the discussion to be supported on Un*x,
A> many Windows, and Mac OSX. So I expected the core routine
A> to be something like below. I admit to being very new to
A> these considerations however. Additionally, your proposed
A> path seems to fully address my problem---thanks!
A> Alan Isaac
A> def getHomeDir():
A> '''
A> see
A> http://mail.python.org/pipermail/python-list/2005-February/263921.html
A> Find user's home directory if possible, otherwise return None.
A> '''
A> path=''
A> try:
A> path=os.path.expanduser("~")
A> except:
A> pass
A> if not os.path.isdir(path):
A> for evar in ('HOME', 'USERPROFILE', 'TMP'):
A> try:
A> path = os.environ[evar]
A> if os.path.isdir(path):
A> break
A> except: pass
A> if path: return path
A> else: return None
Yes this would work well, but as Fernando mentioned, he did not want
to break the code for existing users.
(I would remove the try..except around os.path.expanduser, since it
ALWAYS returns something. And me, I would always just return path, so
that I know I have a string, but can still easily check it for a
boolean if I wished.)
--
Jerry
___________________________
A ship in the harbor is safe,
but that is not what ships are built for. --John A Shedd
=========
(Python 2.3.5, IPython 0.6.13, Windows XP)