how to know whether the item in a diretory is a file/directory

chris liechti cliechti at
Wed Aug 1 04:26:14 CEST 2001

"sdf" <wqh-2 at> wrote in
news:mailman.996630962.3179.python-list at 
> I want to process all the files in a diretory,and ignore the
> subdirectorys in it 
> ,I use  os.listdir() to list all the items,but I do not know whether
> the selected 
> item is a file

you have deleted the documentation? take your browser point it to the doc 
dir in you python installation directory and then look at the module "os" 
there you find Files and Directories", then please look what's available 
there and maybe you find "stat". when you are there you find a link to the 
module "stat". there is also an example in that module which does exactly 
what you want.

sorry for the bad tone in the reply but you post many questions that are 
quite well answered in the python documentation.

neverthles - enjoy programming python :-)

chris <cliechti at>

More information about the Python-list mailing list