Automatically creating a HOME environ variable on Windows?

jim.eggleston at gmail.com jim.eggleston at gmail.com
Fri Oct 28 21:27:16 EDT 2005


Windows doesn't have a HOME environment variable, but it does have
HOMEDRIVE and HOMEPATH. Could Windows versions of Python automatically
populate os.environ with HOME, where HOME =
os.path.join(os.environ['HOMEDRIVE'], os.environ['HOMEPATH'])?

If this was done, then modules such as pdb, which load resource files
from HOME, would work under Windows.

Alternatively, here is a patch to make pdb.py read .pdbrc under
Windows.

*** pdb_orig.py Mon Jun 16 01:26:30 2003
--- pdb.py      Sat Oct 29 11:11:07 2005
***************
*** 65,72 ****
--- 65,76 ----

          # Read $HOME/.pdbrc and ./.pdbrc
          self.rcLines = []
+         envHome = ''
          if 'HOME' in os.environ:
              envHome = os.environ['HOME']
+         elif 'HOMEDRIVE' in os.environ and 'HOMEPATH' in os.environ:
+             envHome = os.path.join(os.environ['HOMEDRIVE'],
os.environ['HOMEPATH'])
+         if envHome:
              try:
                  rcFile = open(os.path.join(envHome, ".pdbrc"))
              except IOError:




More information about the Python-list mailing list