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


Groups > comp.lang.python > #2303

Re: In List Query -> None Case Sensitive?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.062
X-Spam-Evidence '*H*': 0.88; '*S*': 0.00; 'match.': 0.09; 'subject:None': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'subject:Query': 0.16; '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0': 0.16; 'subject:List': 0.20; 'header:In-Reply-To:1': 0.22; 'received:209.85.214.174': 0.23; 'received:mail- iw0-f174.google.com': 0.23; 'easiest': 0.25; 'instead': 0.26; 'chris': 0.27; 'message-id:@mail.gmail.com': 0.28; "doesn't": 0.28; 'subject:?': 0.29; 'fri,': 0.29; 'list': 0.30; 'equally': 0.31; 'marco': 0.31; 'to:addr:python-list': 0.32; 'regular': 0.34; 'there': 0.35; 'force': 0.35; 'doing': 0.36; 'case': 0.37; 'received:209.85': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'files': 0.38; 'received:209.85.214': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.39; "it's": 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'full': 0.62; 'media]': 0.84; 'smooth': 0.84; 'subject:Case': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=5t9qOa9XwHZ1XG7/FoDTz/gtYZZcFTJYGlecCWZsE0M=; b=lRUSkOrh8xBcAAzhuZ54YgmnQwsoJhej62GZLk6mIKU5oEes/TUyu6cn9WbdN/QeyY XhS2LcbXzsRxkym5DP2fWctgbnokMvWTx9lyWyAM8mOC6hCwUPsi15sIoesuyNTE3P6b 2sqcjmFEtPrAC1KPYsjOEXMvOik+zWHLx4NwE=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=r/bR6ItUww3UaX+BFkCOBJilgsbaaZRZlUHnDy+fpypYOgy1tVi/9TC6TJlFBFrLVy R5XlrMYH/KdzGAxkkIb/f8J2/v+zYOnUv3WEIquB8AJDmeBIn+8xEeDcaRfVPHNmsDZU e9198vw3PS0LpfFLV3WLP8Sl3lO/uXrz3FONs=
MIME-Version 1.0
In-Reply-To <BB7D4CEE02C38D499DF7CA5B8D08578721DDDF7E@AMSXMBX01.bskyb.com>
References <BB7D4CEE02C38D499DF7CA5B8D08578721DDDF7E@AMSXMBX01.bskyb.com>
Date Fri, 1 Apr 2011 08:51:12 +1100
Subject Re: In List Query -> None Case Sensitive?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.45.1301608275.2990.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 82.94.164.166
X-Trace 1301608276 news.xs4all.nl 81482 [::ffff:82.94.164.166]:54326
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:2303

Show key headers only | View raw


On Fri, Apr 1, 2011 at 8:14 AM, Wehe, Marco <Marco.Wehe@bskyb.com> 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?
>
>                                     if iFile in media:

If you know they're *all* uppercase, the easiest way is to replace
this line with:

if iFile.upper() in media:

It's not case insensitive per se. For true case insensitivity, force
media[] to be all-uppercase too:

media=[f.upper() for f in media]

Or you can equally use lower() instead of upper().

Chris Angelico

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


Thread

Re: In List Query -> None Case Sensitive? Chris Angelico <rosuav@gmail.com> - 2011-04-01 08:51 +1100

csiph-web