os.path.isfile and wildcard for directory name

smainklh at free.fr smainklh at free.fr
Thu Dec 30 03:36:06 EST 2010



Hi everyone,

I'm just beginning to learn python language and i'm trying to do something and i
can't figure it out.

I want to test if a file exists but my path contain a directory name that
differs from a server to another.
In shell i would have done something like that :

#!/bin/bash

mypath=/dire*/directory02/
myfile=filename

myfile=toto

if [ -f $mypath/$myfile ]
   then
       echo "File $file exists"
fi


How can i do the same thing (wildcard in a directory name) in python please ?

Thanks for your help !

Smaine



More information about the Python-list mailing list