Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.126 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.78; '*S*': 0.03; 'subject:not': 0.03; 'suppose': 0.07; 'subject: \n ': 0.16; 'header:User-Agent:1': 0.23; 'extension': 0.26; 'subject:that': 0.31; 'file': 0.32; '(e.g.': 0.33; 'subject:?': 0.36; 'list': 0.37; 'skip:o 20': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'how': 0.40; 'more': 0.64; 'determine': 0.67; 'subject:Test': 0.84; 'subject:very': 0.91 X-SENDER-IP: [213.112.49.116] X-LISTENER: [smtp.bredband.net] X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApEMAI2h4lPVcDF0PGdsb2JhbABagkBMgRSDDYQ3qmyaUIdNgS8FAQEBATiEYxV2AgUhAhECMicIAQGIQgGdfY8rll2BLI49gmOBUgEEtFI X-IPAS-Result: ApEMAI2h4lPVcDF0PGdsb2JhbABagkBMgRSDDYQ3qmyaUIdNgS8FAQEBATiEYxV2AgUhAhECMicIAQGIQgGdfY8rll2BLI49gmOBUgEEtFI X-IronPort-AV: E=Sophos;i="5.01,813,1400018400"; d="scan'208";a="624269118" Date: Wed, 06 Aug 2014 23:46:18 +0200 From: Virgil Stokes User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: python-list@python.org Subject: Test for an empty directory that could be very large if it is not empty? Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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: 5 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407363468 news.xs4all.nl 2845 [2001:888:2000:d::a6]:56000 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75813 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?