On 01/22/2014 04:58 PM, Larry Martell wrote:
I have the need to check for a files existence against a string, but I
need to do case-insensitively.
This should get you going. As it is, it will check the /entire/ string you send in even if it has path parts to it, and
there are probably other idiosyncrasies that you may want to change to match your needs.
---------------------------
def exists(filename, ci=False):
from glob import glob
search = filename
if ci:
new_search = []
for ch in filename:
new_search.append('[%s%s]' % (ch.lower(), ch.upper()))
search = ''.join(new_search)
found = glob(search)
return bool(found)
---------------------------
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list