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


Groups > comp.lang.python > #2302

In List Query -> None Case Sensitive?

From "Wehe, Marco" <Marco.Wehe@bskyb.com>
Subject In List Query -> None Case Sensitive?
Date 2011-03-31 21:14 +0000
Newsgroups comp.lang.python
Message-ID <mailman.44.1301607001.2990.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi,

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)



This is the real file name that I can't find:
Lihou Island.mov

Thanks a lot,
Marco
[sky]
Marco Wehe
Visual Effects TD
VFX/3D
BSkyB, Sky 2, Grant Way, Isleworth, Middlesex TW7 5QD
t: +44 (0) 20 7805 8035
f: +44 (0) 20 7805 6577
e: marco.wehe@bskyb.com<mailto:smarco.wehe@bskyb.com>



Information in this email including any attachments may be privileged, confidential and is intended exclusively for the addressee. The views expressed may not be official policy, but the personal views of the originator. If you have received it in error, please notify the sender by return e-mail and delete it from your system. You should not reproduce, distribute, store, retransmit, use or disclose its contents to anyone. Please note we reserve the right to monitor all e-mail communication through our internal and external networks. SKY and the SKY marks are trade marks of British Sky Broadcasting Group plc and are used under licence. British Sky Broadcasting Limited (Registration No. 2906991), Sky Interactive Limited (Registration No. 3554332), Sky-In-Home Service Limited (Registration No. 2067075) and Sky Subscribers Services Limited (Registration No. 2340150) are direct or indirect subsidiaries of British Sky Broadcasting Group plc (Registration No. 2247735). All of the companies mentioned in this paragraph are incorporated in England and Wales and share the same registered office at Grant Way, Isleworth, Middlesex TW7 5QD.

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


Thread

In List Query -> None Case Sensitive? "Wehe, Marco" <Marco.Wehe@bskyb.com> - 2011-03-31 21:14 +0000
  Re: In List Query -> None Case Sensitive? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-03-31 23:42 +0000
    Re: In List Query -> None Case Sensitive? Chris Angelico <rosuav@gmail.com> - 2011-04-01 11:01 +1100
      Re: In List Query -> None Case Sensitive? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-01 12:49 +0000

csiph-web