os.path.isfile and wildcard for directory name
Cameron Simpson
cs at zip.com.au
Thu Dec 30 04:04:44 EST 2010
On 30Dec2010 09:36, smainklh at free.fr <smainklh at free.fr> wrote:
| 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 ]
[...]
Check out the glob module:
http://docs.python.org/library/glob.html#module-glob
Use it to do the glob, then os.path.isfile with a path constructed from
the result:
http://docs.python.org/library/os.path.html#os.path.isfile
Cheers,
--
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/
Any company large enough to have a research lab
is large enough not to listen to it. - Alan Kay
More information about the Python-list
mailing list