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. A directory (please stop calling them "folders") can only be removed if it's empty. Reinhold -- http://mail.python.org/mailman/listinfo/python-list