Python doesn't see the directories I create

lupino no_mail at someprovider.it
Thu Aug 30 05:19:45 EDT 2007


Ciao mr_gadget,

> When I create a subfolder, python is not seeing it. Can someone please 
> explain this behaviour ? I just started with python, read the tutorial over 
> the weekend and am writing my very first script. So I may not be seeing 
> something. Both os.path and glob.glob seem not to see a folder I created. 
> Other sibling folders seem to work fine. On a whim I tried paths with \\ 
> double slashes and that worked. But why should single slashes work for some 
> folders and not for others ??

Instead of relying on your own error-prone ability of using forward and back
slashes as path separators, try to get as much as possible from python. ;)

You can use os.sep as a cross-platform path separator, instead of forward
slashes or escaped back slashes.

Moreover you can use the os.path.join function to let python take care of your
problem. :)

>>> os.path.join("C:", "Programs", "MySubFolder")
'C:/Programs/MySubFolder'

HTH,

-- 
[ Andrea Spadaccini - a.k.a. lupino3 - GLUGCT - from Catania - ICQ : 91528290 ]
[ GPG ID: 5D41ABF0 - key on keyservers - Debian GNU / Linux - Kernel 2.6.18.4 ]
[ Linux Registered User 313388 - a(dot)spadaccini(at)catania(dot)linux(dot)it ]
[       Computers are high-speed idiots, programmed by low-speed idiots       ]



More information about the Python-list mailing list