Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'mrab': 0.05; 'string': 0.09; '22,': 0.09; 'filenames': 0.09; 'os.path': 0.09; 'windows,': 0.09; 'jan': 0.12; 'efficiency.': 0.16; 'for,': 0.16; 'plan.': 0.16; 'simplest': 0.16; 'subject:Case': 0.16; 'subject:exists': 0.16; 'subject:insensitive': 0.16; 'there?': 0.16; '(you': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'to:name:python-list@python.org': 0.22; 'this?': 0.23; 'string,': 0.24; 'compare': 0.26; 'switch': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'existence': 0.31; 'larry': 0.31; 'linux.': 0.31; 'anyone': 0.31; 'file': 0.32; 'up.': 0.33; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'example,': 0.37; 'too': 0.37; 'to:addr:python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'name': 0.63; 'different': 0.65; 'discover': 0.82 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=dj8WSDoD7pbtLZ1WRAbFpXRjGQb6TF5CR6eN2ea30hg=; b=INQEZoBrD0qwfA5YZk+F+2hXVlsMTIL+L3tyAVc4P8iWjodWgyTiOtngfDGVIsMQE1 pAF/TPmwBAvfdsqZaDJjNy3qEVZ1BiqyTaonnYDsouQGNMtQMxxNuuPbwvk4Zf441S9p YnF+eRWBz1xGKNU5ghhMHKYJ9pP1oxzcLOsPT7yv3ASvCvgrtnCRHoqccvGRfYtGWEBk PSUr+MkD+YxVuzB4rIrOV7bNdM+MrQp2Mn+4p2CjVIP9yLaErc5dIbjDk1OxhflYb93X w9CExvgraMzZPhpaDGEPX/Jli0WXuWgJIY4qPC7AG41gFKTERPy7+JcF8nMDXN1aj8DY dBsg== MIME-Version: 1.0 X-Received: by 10.58.85.133 with SMTP id h5mr3350315vez.4.1390451131770; Wed, 22 Jan 2014 20:25:31 -0800 (PST) In-Reply-To: <52E07014.2010203@mrabarnett.plus.com> References: <52E07014.2010203@mrabarnett.plus.com> Date: Wed, 22 Jan 2014 21:25:31 -0700 Subject: Re: Case insensitive exists()? From: Larry Martell To: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390451140 news.xs4all.nl 2961 [2001:888:2000:d::a6]:57458 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64565 On Wed, Jan 22, 2014 at 6:27 PM, MRAB wrote: > On 2014-01-23 00:58, Larry Martell wrote: >> >> I have the need to check for a files existence against a string, but I >> need to do case-insensitively. I cannot efficiently get the name of >> every file in the dir and compare each with my string using lower(), >> as I have 100's of strings to check for, each in a different dir, and >> each dir can have 100's of files in it. Does anyone know of an >> efficient way to do this? There's no switch for os.path that makes >> exists() check case-insensitively is there? >> > You don't say which OS. Filenames in Windows, for example, are already > case-insensitive. Linux. > Try writing it the simplest and cleanest way, without thinking about > efficiency. If you discover that it really is too slow (you can always > try a smaller test case initially), then you can think about how to > speed it up. Yes, that's my plan.