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

chris liechti cliechti at mails.ch
Tue Jul 31 22:26:14 EDT 2001


"sdf" <wqh-2 at 263.net> wrote in
news:mailman.996630962.3179.python-list at python.org: 
> 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 mails.ch>




More information about the Python-list mailing list