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


Groups > comp.lang.python > #2304 > unrolled thread

Re: In List Query -> None Case Sensitive?

Started byEthan Furman <ethan@stoneleaf.us>
First post2011-03-31 15:05 -0700
Last post2011-03-31 15:05 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: In List Query -> None Case Sensitive? Ethan Furman <ethan@stoneleaf.us> - 2011-03-31 15:05 -0700

#2304 — Re: In List Query -> None Case Sensitive?

FromEthan Furman <ethan@stoneleaf.us>
Date2011-03-31 15:05 -0700
SubjectRe: In List Query -> None Case Sensitive?
Message-ID<mailman.47.1301608486.2990.python-list@python.org>
Wehe, Marco wrote:
> I am doing a search through a list of files but the text the casing 
> doesn't match. My list is all upper case but the real files are all 
> different. Is there a smooth way of searching through the list without 
> going full on regular expressions?
> 
> path = "V:\\Jinsy\\incoming\\assets"
> media=["LIHOU ISLAND.MOV", "MVI_1449.MOV"]
> def FindMedia(path):
>     result = []
>     for root, dirs, files in os.walk(path):
>         for iFile in files:
>             if iFile in media:
>                 filePath = os.path.join(root, iFile)
>                 result.append(filePath)
>     return result
> for filePath in FindMedia(path):
>     log(filePath)


Change

if iFile in media:

to

if iFile.upper() in media:

and keep media all upper-case.

~Ethan~

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web