Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!ecngs!feeder2.ecngs.de!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:not': 0.03; 'compact': 0.09; 'performs': 0.09; 'seemed': 0.09; 'windows,': 0.09; 'python': 0.11; 'windows': 0.15; '>on': 0.16; '>to': 0.16; 'empty,': 0.16; 'forgiveness': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'subject: \n ': 0.16; 'applies': 0.16; 'wrote:': 0.18; 'properly': 0.19; '(the': 0.22; 'header:User-Agent:1': 0.23; 'directory.': 0.24; 'greg': 0.24; 'cheers,': 0.24; 'header:In-Reply-To:1': 0.27; 'unix': 0.29; "doesn't": 0.30; 'along': 0.30; 'subject:that': 0.31; 'file': 0.32; "can't": 0.35; 'really': 0.36; 'received:com.au': 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'list': 0.37; 'remote': 0.38; 'received:211': 0.38; 'to:addr :python-list': 0.38; 'bad': 0.39; 'to:addr:python.org': 0.39; 'release': 0.40; 'remove': 0.60; 'disclaimer:': 0.60; 'course': 0.61; 'content-disposition:inline': 0.62; 'offer': 0.62; 'complete': 0.62; 'here': 0.66; 'determine': 0.67; 'sport': 0.74; 'music': 0.75; 'destructive': 0.84; 'sound.': 0.84; 'subject:Test': 0.84; 'subject:very': 0.91; 'imagine': 0.93; 'wanting': 0.93 Date: Thu, 7 Aug 2014 17:08:55 +1000 From: Cameron Simpson To: python-list@python.org Subject: Re: Test for an empty directory that could be very large if it is not empty? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) References: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=Ap/XgoNP c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=v3k3jNvI0ygA:10 a=HHRd_vq2tI4A:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=noLf4L212slAtKhVstAA:9 a=CjuIK1q_8ugA:10 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407395347 news.xs4all.nl 2904 [2001:888:2000:d::a6]:50429 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75838 On 07Aug2014 18:14, Greg Ewing 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 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