Re: HOME Directory in posix and nt

Discussion in 'Python' started by Jeff Epler, Aug 3, 2003.

  1. Jeff Epler

    Jeff Epler Guest

    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
    Jeff Epler, Aug 3, 2003
    #1
    1. Advertising

  2. Jeff Epler

    Jarek Zgoda Guest

    Jeff Epler <> 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: http://zgoda.jogger.pl/
    Jarek Zgoda, Aug 3, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DanielESFA

    Putting stuff in $HOME (POSIX)

    DanielESFA, May 23, 2005, in forum: C++
    Replies:
    5
    Views:
    354
    DanielESFA
    May 23, 2005
  2. john
    Replies:
    4
    Views:
    656
    Jim Higson
    Jun 15, 2006
  3. nancyflorida
    Replies:
    0
    Views:
    320
    nancyflorida
    Nov 12, 2007
  4. nancyflorida
    Replies:
    0
    Views:
    305
    nancyflorida
    Nov 12, 2007
  5. * Its my Pleasure *
    Replies:
    0
    Views:
    364
    * Its my Pleasure *
    Feb 20, 2008
Loading...

Share This Page