Case insensitive exists()?
Roy Smith
roy at panix.com
Wed Jan 22 20:27:03 EST 2014
In article <mailman.5855.1390439920.18130.python-list at python.org>,
Larry Martell <larry.martell at gmail.com> wrote:
> The issue is that I run a database query and get back rows, each with
> a file path (each in a different dir). And I have to check to see if
> that file exists. Each is a separate search with no correlation to the
> others. I have the full path, so I guess I'll have to do dir name on
> it, then a listdir then compare each item with .lower with my string
> .lower. It's just that the dirs have 100's and 100's of files so I'm
> really worried about efficiency.
Oh, my, this is a much more complicated problem than you originally
described.
Is the whole path case-insensitive, or just the last component? In
other words, if the search string is "/foo/bar/my_file_name", do all of
these paths match?
/FOO/BAR/MY_FILE_NAME
/foo/bar/my_file_name
/FoO/bAr/My_FiLe_NaMe
Can you give some more background as to *why* you're doing this?
Usually, if a system considers filenames to be case-insensitive, that's
something that's handled by the operating system itself.
More information about the Python-list
mailing list