Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75838
| Date | 2014-08-07 17:08 +1000 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: Test for an empty directory that could be very large if it is not empty? |
| References | <c4gjqvF8cmiU1@mid.individual.net> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12721.1407395347.18130.python-list@python.org> (permalink) |
On 07Aug2014 18:14, Greg Ewing <greg.ewing@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 opendir() and readdir(), which Python doesn't currently >wrap. [...] On UNIX (the OP seemed to be using Windows, alas), if you are prepared to be destructive you can just do an rmdir. It will fail if the directory is not empty, and performs ok on the hypothesised remote once-ginormous directory. The commonest reason for wanting to know if a directory is empty that I can imagine is when you want to remove it, and if that applies here it is better to just try to remove it and ask for forgiveness later. Disclaimer: Windows may not offer this handy safety net. Cheers, Cameron Simpson <cs@zip.com.au> Of course no description of a Ducati engine is complete without mentioning the sound. That deep bass exhaust rumble along with the mechanical music of the desmodromic valves...too bad it isn't available on compact disc. - Sport Rider, evidently before the release of the "Ducati Passions" CD
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Test for an empty directory that could be very large if it is not empty? Virgil Stokes <vs@it.uu.se> - 2014-08-06 23:46 +0200
Re: Test for an empty directory that could be very large if it is not empty? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-08-07 18:14 +1200
Re: Test for an empty directory that could be very large if it is not empty? Cameron Simpson <cs@zip.com.au> - 2014-08-07 17:08 +1000
Re: Test for an empty directory that could be very large if it is not empty? Roy Smith <roy@panix.com> - 2014-08-07 07:54 -0400
Re: Test for an empty directory that could be very large if it is not empty? Peter Otten <__peter__@web.de> - 2014-08-07 14:06 +0200
Re: Test for an empty directory that could be very large if it is not empty? Tim Chase <python.list@tim.thechases.com> - 2014-08-07 07:05 -0500
Re: Test for an empty directory that could be very large if it is not empty? Roy Smith <roy@panix.com> - 2014-08-07 08:19 -0400
Re: Test for an empty directory that could be very large if it is not empty? Tim Chase <python.list@tim.thechases.com> - 2014-08-07 12:37 -0500
Re: Test for an empty directory that could be very large if it is not empty? Roy Smith <roy@panix.com> - 2014-08-07 21:10 -0400
Re: Test for an empty directory that could be very large if it is not empty? John Gordon <gordon@panix.com> - 2014-08-07 20:15 +0000
csiph-web