On windows 7, when I run this Python 2.7 code, "NOT file" prints, but the file is there, its not read only, the folder is not read only, none of its parents are read only.
if os.path.exists('D:\testfiles\mysub\GraphiteController.js'):
print "IS file"
else:
print "NOT file"
sys.exit(1)
If I move the file to d:\myother directory
, prints "IS file".
If I move the file to d:\testfiles directory
, prints "NOT file".
I tried this on another windows machine, same problem. Very strange.
It's because '\t' is a tab character. Use forward slashes in your paths or use raw strings:
if os.path.exists('D:/testfiles/mysub/GraphiteController.js'):
or
if os.path.exists(r'D:\testfiles\mysub\GraphiteController.js'):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With