Reinhold Birkenfeld wrote:
> could ildg wrote:
> 
>>I want to check if a folder named "foldername" is empty.
>>I use os.listdir(foldername)==[] to do this,
>>but it will be very slow if the folder has a lot of sub-files.
>>Is there any efficient ways to do this?
> 
> 
> try:
>     os.rmdir(path)
>     empty = True
> except OSError:
>     empty = False
> 
> should be efficient.

But it removes the folder if it is empty. Perhaps it's not efficient to 
create the folder again.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to