I have the following code which checks if the directory exists
def download(id, name, bar):
cwd = os.getcwd()
dir = os.path.join(cwd,bar)
partial = os.path.join(cwd, id + ".partial")
print os.path.isdir(dir)
if(os.path.isdir(dir)):
print "dir exists"
dir_match_file(dir, bar)
else:
print dir
For a directory that actually exists, it returns "False". Here is the output:
False
/scratch/rists/djiao/Pancancer/RNA-seq/CESC/TCGA-BI-A0VS-01A-11R-A10U-07
When I go to python interactive session and type in os.path.isdir("/scratch/rists/djiao/Pancancer/RNA-seq/CESC/TCGA-BI-A0VS-01A-11R-A10U-07"), it returns "true".
Why does it say false when the folder exists?
print dirtoprint(repr(dir)). Let's see if there is some "invisible" character there such as a CR/LF at the end. - unutburepr(obj)returns astrwhich is intended to be an unambiguous representation of the object. It's useful to inspectbasestrings(strs orunicode) usingreprsince it will tell you exactly what bytes or code points thebasestringis composed of. - unutbudiris a built-in function. Better to pick a different variable name - chaimp