os.path weirdness

Jeff Layton jeffrey.b.layton at lmco.com
Tue Jun 17 11:18:21 EDT 2003


Hello,

    I'm working on a simple python script on a
Linux box (RH 7.3 - Python 1.5.2) to check if
a file exists. A simple example looks like:



#!/usr/bin/python

import os.path

filep="/home1/laytojb/TEMP/tet.out"
print "type: ",type(filep)
if os.path.isfile(filep): #{
     print "Found tet.out"
else:
     print "Cannot find tet.out"
#}



This simple script works correctly and finds the
file tet.out.
    However, when I do virtually the same thing
in a much longer script, it can never find the
file, even though it exists. I've checked my spelling
many times, I've checked that the argument to
os.path.isfile() is a string with no blank spaces
(used string.stip() to peel off leading and trailing
spaces). I still can't seem to find the file.
    I'm pulling out the few hairs I have left on the
top of my head. Does anybody have any suggestions
about what to look for?

TIA!

Jeff





More information about the Python-list mailing list