Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: HOME Directory in posix and nt

Reply
Thread Tools

Re: HOME Directory in posix and nt

 
 
Jeff Epler
Guest
Posts: n/a
 
      08-03-2003
os.environ holds the system environment, so
home = os.environ['HOME']
on unix, and
home = os.environ['HOMEPATH']
on windows might be what you want.

You could also try
home = os.path.expanduser("~")
which looks at HOME and pwd.getpwuid on unix, and at HOME, HOMEPATH, and
HOMEDRIVE on NT.

Jeff

 
Reply With Quote
 
 
 
 
Jarek Zgoda
Guest
Posts: n/a
 
      08-03-2003
Jeff Epler <(E-Mail Removed)> pisze:

> os.environ holds the system environment, so
> home = os.environ['HOME']
> on unix, and
> home = os.environ['HOMEPATH']
> on windows might be what you want.
>
> You could also try
> home = os.path.expanduser("~")
> which looks at HOME and pwd.getpwuid on unix, and at HOME, HOMEPATH, and
> HOMEDRIVE on NT.


Unfortunately, the latest is known to give strange results on Windows
2000. On my machine at work (W2K Sp3) it just returns string
'%USERPROFILE%'. On my wife's WinXP Pro Sp1 it returns 'C:\', which is
crap, since home directory is set to 'C:\Documents and Settings...'
(that's the value of HOMEDRIVE + HOMEPATH and of USERPROFILE variables).

--
Jarek Zgoda
Registered Linux User #-1
http://www.zgoda.biz/ JID:(E-Mail Removed) http://zgoda.jogger.pl/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory Nathan Sokalski ASP .Net 2 09-06-2007 03:58 PM
Directory structure of home directory? john HTML 4 06-15-2006 06:50 PM
Putting stuff in $HOME (POSIX) DanielESFA C++ 5 05-23-2005 10:34 PM
POSIX Threading and Segmentation Fault... DanielEKFA C++ 16 05-16-2005 10:27 AM
STL map and Posix Threads Chaman Singh C++ 3 04-09-2004 07:02 PM



Advertisments