[Tutor] Checking for the existence of a file
Isaac Hall
hall@ouhep1.nhn.ou.edu
Tue Jan 21 14:35:02 2003
Hi python list!
I was wondering if someone could point me to some of the methods available
for checking to see whether a file called aaaa.bbb exists through a python
script. The current method I use is:
if os.popen('ls '+filename).read()[:-1]==filename:
exists=1
else:
exists=0
however, sometimes, I run into a small problem with that....
sometimes, but not all the time, the script will tell me that the Index is
out of range. I am unable to replicate this error in the interactive
interpreter, and I was wondering if there is a better way to do this.
Thanks
Ike
--