Thank you . so you mean that this is not platform-independent?
On 8/8/05, Neil Hodgson <[EMAIL PROTECTED]> wrote: > could ildg: > > > 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? > > The first thing to do is measure the performance of this operation > in the context of your application to see if it is really worth extra > effort. > Tweaking this will depend on the platform. On Windows you can use > ctypes and the system functions FindFirstFile/FindNextFile/FindClose, > finishing once you see a single file. Directories always contain "." and > ".." entries so they should be ignored. On other platforms there will be > similar low level functions. > > Neil > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list