import os print os.listdir("c:\\a\\b\\") dirname = "c:\\" print os.listdir(dirname) [f for f in os.listdir(dirname) if os.path.isfile(os.path.join(dirname, f))] [f for f in os.listdir(dirname) if os.path.isdir(os.path.join(dirname, f))]