Interview Questions

Why does os.path.isdir() fail on NT shared directories?

Python Questions and Answers


(Continued from previous question...)

Why does os.path.isdir() fail on NT shared directories?

The solution appears to be always append the "\" on the end of shared drives.

>>> import os
>>>os.path.isdir( '\\\\rorschach\\public')
0
>>>os.path.isdir( '\\\\rorschach\\public\\')
1

It helps to think of share points as being like drive letters. Example:

k: is not a directory
k:\ is a directory
k:\media is a directory
k:\media\ is not a directory

The same rules apply if you substitute "k:" with "\conkyfoo":

\\conky\foo is not a directory
\\conky\foo\ is a directory
\\conky\foo\media is a directory
\\conky\foo\media\ is not a directory

(Continued on next question...)

Other Interview Questions