How can I check if the listdir result a directory?

Tim Daneliuk tundra at tundraware.com
Fri Mar 23 06:53:22 CET 2007


Plissken.s at gmail.com wrote:
> I have the following code which list out all the files/directories
> under the current directory.
> 
> But how can I find out if 'f' is a directory?
> 
> for f in os.listdir("."):
>      // how can I check if 'f' a directory?
> 

Try os.path.isdir()

-- 
----------------------------------------------------------------------------
Tim Daneliuk     tundra at tundraware.com
PGP Key:         http://www.tundraware.com/PGP/



More information about the Python-list mailing list