Re: %SystemDrive%
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: %SystemDrive%

From: Atanas Banov <enterr@gmail.com>
Date: Wed Feb 15 2006 - 21:35:46 CET

using
   os.chdir('/')
   os.getcwd()
is plain wrong in Windows.

what it does is change the current directory to root of the CURRENT
DRIVE (i.e. the drive of the directory where script was started from),
not the system drive. for example, if current directory was
c:\myscripts and system drive is d:, this will return c:\ and not d:\.
hence chdir doesnt do any good, you can do os.getcwd()[:3] with the
same success.

os.environ['SYSTEMDRIVE'] is the right way to go.
btw it correctly returns just drive letter and colon, a drive name
doesnt include [back]slash
Received on Sun Apr 30 09:25:34 2006