Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #75848 > unrolled thread

Re: Test for an empty directory that could be very large if it is not empty?

Started byAkira Li <4kir4.1i@gmail.com>
First post2014-08-07 16:19 +0400
Last post2014-08-07 16:19 +0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Test for an empty directory that could be very large if it is not empty? Akira Li <4kir4.1i@gmail.com> - 2014-08-07 16:19 +0400

#75848 — Re: Test for an empty directory that could be very large if it is not empty?

FromAkira Li <4kir4.1i@gmail.com>
Date2014-08-07 16:19 +0400
SubjectRe: Test for an empty directory that could be very large if it is not empty?
Message-ID<mailman.12726.1407413974.18130.python-list@python.org>
Virgil Stokes <vs@it.uu.se> writes:

> Suppose I have a directory C:/Test that is either empty or contains
> more than 2000000 files, all with the same extension (e.g. *.txt). How
> can I determine if the directory is empty WITHOUT the generation of a
> list of the file names in it (e.g. using os.listdir('C:/Test')) when
> it is not empty?

  def is_empty_dir(dirpath):
      return next(scandir(dirpath), None) is None

 https://github.com/benhoyt/scandir


 --
 Akira

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web