Q:

os.listdir etc fails on shared windows path (Python 2.5)

I am seeing some weird behavior while parsing shared paths (shared paths on server, e.g. \storage\Builds)
I am reading text file which contains directory paths which I want to process further.  In order to do so I do as below:
def toWin(path):
    return path.replace("\\", "\\\\")

for line in open(fileName):
    l = toWin(line).strip()
    if os.path.isdir(l):
        print l # os.listdir(l) etc..

This works for local directories but fails for paths specified on shared system. 
e.g. 
    E:\Test -- works
    \\StorageMachine\Test -- fails [internally converts to \\\\StorageMachine\\Test]
    \\StorageMachine\Test\ -- fails  [internally converts to \\\\StorageMachine\\Test\\]

But if I open python shell, import script and invoke function with same path string then it works! 
It seems that parsing windows shared paths is behaving differently in both cases.  
Any ideas/suggestions? 

A:

Have to convert input to forward slash (unix-style) for os.*  modules to parse correctly. 
changed code as below
def toUnix(path):
    return path.replace("\\", "/")

Now all modules parse correctly.