navigating through different drive letters in python os.system
Question: I am having a problem with a bit of code on one windows machine but not all
windows machines. i have the following code:

    
    
    path = "F:/dir/"
    os.system(path[0:2] + " && cd " + path + " && git init")
    

On all but one of my windows systems it runs fine but on a windows 2003 server
it gives a "directory not found" error but if i run the same command flat from
the command prompt than it works.

I'm sorry if my question comes off as vague but I'm totally stumped


Answer: [os.path](http://docs.python.org/library/os.path.html) contains many usefull
path manipulation functions. Probably just handling the path cleanly will
resolve your problem.

    
    
    >>> import os
    >>>
    >>>
    >>> path = "F:/dir/"
    >>>
    >>> clean_path = os.path.normpath(path)
    >>> clean_path
    'F:\\dir'
    >>> drive, directory = os.path.splitdrive(clean_path)
    >>> drive
    'F:'
    >>> directory
    '\\dir'
    

Also, you might want to look into using the
[subprocess](http://docs.python.org/library/subprocess.html) module, it gives
you more control over processes.

[Replacing Older Functions with the subprocess
Module](http://docs.python.org/library/subprocess.html#subprocess-
replacements)

