Find if a file existing within 1000s of folder/sub-folder - each file has a unique presence

Tim Golden mail at timgolden.me.uk
Thu May 21 10:32:49 EDT 2015


On 21/05/2015 15:14, Grant Edwards wrote:
> On 2015-05-21, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
> 
>> import glob
>> print(glob.glob("c:/abc/def/ghjmain/features/XYZ/*<filename>"))
>>
>> Don't use backslashes \ as they have special meaning to Python. Use forward 
>> slashes and let Python convert them as needed.
> 
> Interesting. I've never heard about this.
> 
> When will Python convert them?
> 

It doesn't: Python passes them on unchanged and Windows accepts them in
all but a few cases.

(Although if any stdlib function were to call, eg, os.path.abspath on a
path before passing it along to Windows then one effect is that the path
is "normalised", ending up with backslashes. So perhaps that does happen
in modules like shutil. Not sure).


TJG



More information about the Python-list mailing list