Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64613

Re: Case insensitive exists()?

From Grant Edwards <invalid@invalid.invalid>
Newsgroups comp.lang.python
Subject Re: Case insensitive exists()?
Date 2014-01-23 14:58 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <lbramg$6qv$1@reader1.panix.com> (permalink)
References <mailman.5853.1390438708.18130.python-list@python.org>

Show all headers | View raw


On 2014-01-23, Larry Martell <larry.martell@gmail.com> 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?

If you're on Unix, you could use os.popen() to run a find command
using -iname.

-- 
Grant Edwards               grant.b.edwards        Yow! I'm DESPONDENT ... I
                                  at               hope there's something
                              gmail.com            DEEP-FRIED under this
                                                   miniature DOMED STADIUM ...

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Case insensitive exists()? Larry Martell <larry.martell@gmail.com> - 2014-01-22 17:58 -0700
  Re: Case insensitive exists()? Roy Smith <roy@panix.com> - 2014-01-22 20:08 -0500
    Re: Case insensitive exists()? Larry Martell <larry.martell@gmail.com> - 2014-01-22 18:18 -0700
      Re: Case insensitive exists()? Roy Smith <roy@panix.com> - 2014-01-22 20:27 -0500
        Re: Case insensitive exists()? Larry Martell <larry.martell@gmail.com> - 2014-01-22 21:24 -0700
        Re: Case insensitive exists()? Chris Angelico <rosuav@gmail.com> - 2014-01-23 15:29 +1100
        Re: Case insensitive exists()? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-01-23 15:43 +0000
        Re: Case insensitive exists()? Larry Martell <larry.martell@gmail.com> - 2014-01-23 12:02 -0700
      Re: Case insensitive exists()? Dan Sommers <dan@tombstonezero.net> - 2014-01-23 07:51 +0000
  Re: Case insensitive exists()? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-23 12:06 +0000
  Re: Case insensitive exists()? Grant Edwards <invalid@invalid.invalid> - 2014-01-23 14:58 +0000

csiph-web