I am creating a Python ISO generation application and I am getting some wierd output from os.path.isdir (). I am running Arch Linux with Python 2.7.1.
I have the following folder structure:
/ home / andrew / create _iso / Raw_Materials /
/ Home / Andrew / create_iso / Raw_Materials / test_cd /
[andrew@Cydonia Raw_Materials]$ ls -l
total 4
drwxr-xr-x 3 andrew andrew 4096 Feb 23 10:20 test_cd
As you can see, test_cd / is a regular Linux folder. However, when I run os.path.isdir (), I get different results depending on whether it is part of a for loop or whether I hardcode it.
import os
>>>for folders in os.listdir('/home/andrew/create_iso/Raw_Materials/'):
... os.path.isdir(folders)
False
>>>os.path.isdir('/home/andrew/create_iso/Raw_Materials/test_cd')
True
I thought that maybe the output that I get from os.listdir () was something strange, but it also looks like a check:
>>>os.listdir('/home/andrew/create_iso/Raw_Materials/')
['test_cd']
Any idea why she treats these cases differently? Thanks in advance.