Odd behaviour of os module with a Win2k shared directory

Roger Upole rupole at hotmail.com
Fri Jun 25 12:01:56 EDT 2004


I think this is actually due to the library removing a trailing backslash.
If you put 2 trailing backslashes on the path to a share, you get True back.
        Roger

"Larry Bates" <lbates at swamisoft.com> wrote in message
news:quGdnZ3Wk6SKpEHdRVn-vA at comcast.com...
> When you access a share on Windows 2000 machine it acts
> as if it is the root directory.  That being said your
> command checked to see if dietplan6 had a file/folder
> inside of it named dietplan6.  If you can see the share
> then it exists.  If you want to test for the existence
> of the dietplan6, you would need to define your share
> one level up in the tree.  Think of it this way, you
> can't test for the existence of the root directory.
>
> HTH,
> Larry Bates
> Syscon, Inc.
>
> "David Hughes" <dfh at forestfield.co.uk> wrote in message
> news:memo.20040625144135.2040A at forestfield.cix.co.uk...
> > I shared a directory, dietplan6, which is actually several levels down
in
> > C:\Program files\ on a Windows 2000 machine, called 'Nom'. When I tried
to
> > check its existence from another Win2k machine, I got the following
> > strange results:
> >
> > Python 2.3.2 (#49, Oct  2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on
> > win32
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> import os
> > >>> pth = r'\\nom\dietplan6'
> > >>> os.path.exists(pth)
> > False
> > >>> os.listdir(pth)
> > ['unins000.dat', 'program', 'database', 'resource', 'doc', 'dlm',
> > 'dp5conv', 'gs', 'Readme.txt', 'dietplan.lic', 'users', 'imports',
> > 'unins000.exe', 'locks']
> > >>> os.path.exists(os.path.join(pth, 'program'))
> > True
> > >>> os.chdir(pth)
> > >>> os.getcwd()
> > '\\\\nom\\dietplan6'
> > >>> os.path.exists(os.getcwd())
> > False
> > >>>
> >
> > --
> > Regards,
> > David Hughes
> >
>
>





More information about the Python-list mailing list