Python 2.7.1: Inconsistent output from os.path.isdir() -
i'm building python iso generation app, , i'm getting wierd output os.path.isdir(). i'm running arch linux python 2.7.1.
i have 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 can see, test_cd/ normal linux folder. however, when run os.path.isdir(), different results depending on whether it's part of loop or whether hard code 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 maybe there wierd in output i'm getting os.listdir(), seems check out:
>>>os.listdir('/home/andrew/create_iso/raw_materials/') ['test_cd']
any idea why it's treating these cases different? in advance.
'test_cd' not directory. need os.path.join
absolute path directory, , call isdir
on that.
Comments
Post a Comment