os.path and Windows UNC paths

Tim Howarth tim at worthy.demon.co.uk
Wed Jul 10 14:02:44 EDT 2002


I've been trying to use os.path.exists and  os.path.isdir on
Windows(2000) UNC paths with Python 2.2 but it doesn't seem to behanve
sensibly.

os.path.isdir('\\\\server\\share') returns negative result when
os.path.listdir('\\\\server\\share') produces a dir listing.

Checking groups.google and the Python faq I found

8.6 Why does o.path.isdir() failon NT shared directories

Which implies it should work if a tralling '\\' is added

but

os.path.isdir('\\\\server\\share\\') still returns negative result

However  os.path.isdir('\\\\server\\share\\\\') returns true.

Is this sensible/to be trusted.

As an aside;

using os.path.isdir(r'\\server\share\') results in a complaint of
invalid token - I thought the r prefix meant use raw string, so why the
error ?

-- 
___
 |im    ---- ARM Powered ----



More information about the Python-list mailing list