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

2014-08-07 Thread Gregory Ewing
Virgil Stokes wrote: How can I determine if the directory is empty WITHOUT the generation of a list of the file names Which platform? On Windows, I have no idea. On Unix you can't really do this properly without access to opendir() and readdir(), which Python doesn't currently wrap. Will

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

2014-08-07 Thread Cameron Simpson
On 07Aug2014 18:14, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Virgil Stokes wrote: How can I determine if the directory is empty WITHOUT the generation of a list of the file names Which platform? On Windows, I have no idea. On Unix you can't really do this properly without access to

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

2014-08-07 Thread Ethan Furman
On 08/06/2014 03:26 PM, Ben Finney wrote: Virgil Stokes v...@it.uu.se writes: Suppose I have a directory C:/Test that is either empty or contains more than 200 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

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

2014-08-07 Thread Tim Chase
On 2014-08-07 11:27, Ben Finney wrote: The difference in timings when serving a web-request are noticeable (in my use-case, I had to change my algorithm and storage structure to simplify/avoid heavily-populated directories) So, if the requirement is “test whether the directory is

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

2014-08-07 Thread Roy Smith
In article c4gjqvf8cm...@mid.individual.net, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: Virgil Stokes wrote: How can I determine if the directory is empty WITHOUT the generation of a list of the file names Which platform? On Windows, I have no idea. On Unix you can't

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

2014-08-07 Thread Peter Otten
Roy Smith wrote: In article c4gjqvf8cm...@mid.individual.net, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: Virgil Stokes wrote: How can I determine if the directory is empty WITHOUT the generation of a list of the file names Which platform? On Windows, I have no idea. On

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

2014-08-07 Thread Tim Chase
On 2014-08-07 07:54, Roy Smith wrote: I wonder if glob.iglob('*') might help here? My glob.iglob() uses os.listdir() behind the scenes (see glob1() in glob.py) -tkc -- https://mail.python.org/mailman/listinfo/python-list

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

2014-08-07 Thread Akira Li
Virgil Stokes v...@it.uu.se writes: Suppose I have a directory C:/Test that is either empty or contains more than 200 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

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

2014-08-07 Thread Roy Smith
In article mailman.12725.1407413212.18130.python-l...@python.org, Tim Chase python.l...@tim.thechases.com wrote: On 2014-08-07 07:54, Roy Smith wrote: I wonder if glob.iglob('*') might help here? My glob.iglob() uses os.listdir() behind the scenes (see glob1() in glob.py) -tkc In

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

2014-08-07 Thread Tim Chase
On 2014-08-07 08:19, Roy Smith wrote: My glob.iglob() uses os.listdir() behind the scenes (see glob1() in glob.py) -tkc In which case, the documentation for iglob() is broken. It says: Return an iterator which yields the same values as glob() without actually storing them all

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

2014-08-07 Thread John Gordon
In mailman.12711.1407363468.18130.python-l...@python.org Virgil Stokes v...@it.uu.se writes: Suppose I have a directory C:/Test that is either empty or contains more than 200 files, all with the same extension (e.g. *.txt). How can I determine if the directory is empty WITHOUT the

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

2014-08-07 Thread Roy Smith
In article mailman.12729.1407433146.18130.python-l...@python.org, Tim Chase python.l...@tim.thechases.com wrote: On 2014-08-07 08:19, Roy Smith wrote: My glob.iglob() uses os.listdir() behind the scenes (see glob1() in glob.py) -tkc In which case, the documentation for

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

2014-08-06 Thread Virgil Stokes
Suppose I have a directory C:/Test that is either empty or contains more than 200 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?

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

2014-08-06 Thread Ben Finney
Virgil Stokes v...@it.uu.se writes: Suppose I have a directory C:/Test that is either empty or contains more than 200 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

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

2014-08-06 Thread Tim Chase
On 2014-08-07 08:26, Ben Finney wrote: Virgil Stokes v...@it.uu.se writes: Suppose I have a directory C:/Test that is either empty or contains more than 200 files, all with the same extension (e.g. *.txt). How can I determine if the directory is empty WITHOUT the generation of a list

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

2014-08-06 Thread Terry Reedy
On 8/6/2014 6:44 PM, Tim Chase wrote: On 2014-08-07 08:26, Ben Finney wrote: Virgil Stokes v...@it.uu.se writes: Suppose I have a directory C:/Test that is either empty or contains more than 200 files, all with the same extension (e.g. *.txt). How can I determine if the directory is empty

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

2014-08-06 Thread Ben Finney
Tim Chase python.l...@tim.thechases.com writes: The difference in timings when serving a web-request are noticeable (in my use-case, I had to change my algorithm and storage structure to simplify/avoid heavily-populated directories) So, if the requirement is “test whether the directory is

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

2014-08-06 Thread Steven D'Aprano
Ben Finney wrote: Virgil Stokes v...@it.uu.se writes: Suppose I have a directory C:/Test that is either empty or contains more than 200 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