Bryan Olson wrote:
To get it with the \, you might use:
os.path.abspath(os.environ['SYSTEMDRIVE'])
wrong!
the result is incorrect if the current directory is different from the
root.
os.chdir(c:\\winxp)
os.path.abspath(os.environ['SYSTEMDRIVE'])
'c:\\winxp'
if you really want
Atanas Banov wrote:
Bryan Olson wrote:
To get it with the \, you might use:
os.path.abspath(os.environ['SYSTEMDRIVE'])
wrong!
the result is incorrect if the current directory is different from the
root.
Oops, sorry. I should know better than to code from what I
think I vaguely
Is there a proper way to get this variable from Windows? I know it's in
the registry, but I'd rather not go there. I could not find a CSIDL
shell constant for it either. I've been doing this:
os.chdir('/')
sys_drive = os.getcwd()
print sys_drive
C:\
This seems too much of a hack and maybe not
On Wed, 2006-02-15 at 14:07, Todd Whiteman wrote:
Another hack:
drive = os.popen(echo %SYSTEMDRIVE%).readline().strip()
rtilley wrote:
Is there a proper way to get this variable from Windows? I know it's in
the registry, but I'd rather not go there. I could not find a CSIDL
shell
Carsten Haese wrote:
Is there a reason why os.environ['SYSTEMDRIVE'] shouldn't work?
Hope this helps
I didn't know it was in os! It returns C: instead of C:\ like my method.
Other than that, it seems to do the trick.
Thank you!
Brad
--
http://mail.python.org/mailman/listinfo/python-list
Another hack:
drive = os.popen(echo %SYSTEMDRIVE%).readline().strip()
rtilley wrote:
Is there a proper way to get this variable from Windows? I know it's in
the registry, but I'd rather not go there. I could not find a CSIDL
shell constant for it either. I've been doing this:
os.chdir
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
--
http://mail.python.org/mailman
Atanas Banov wrote:
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
rtilley wrote:
Carsten Haese wrote:
Is there a reason why os.environ['SYSTEMDRIVE'] shouldn't work?
I didn't know it was in os! It returns C: instead of C:\ like my method.
Other than that, it seems to do the trick.
To get it with the \, you might use:
os.path.abspath(os.environ