Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!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: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; ':-)': 0.06; '>>>>': 0.09; 'from:addr:python': 0.09; 'throw': 0.09; '>>>': 0.12; 'wrote:': 0.14; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'reply-to:addr :python-list': 0.16; 'sensitivity.': 0.16; 'input': 0.17; "wouldn't": 0.17; 'candidate': 0.17; 'header:In-Reply-To:1': 0.21; 'fri,': 0.23; 'received:84': 0.25; 'tests': 0.26; 'subject:how': 0.29; 'least': 0.30; 'it.': 0.31; 'expression': 0.32; 'steven': 0.32; 'to:addr:python-list': 0.33; 'example,': 0.35; 'option': 0.35; 'there': 0.35; 'header:User-Agent:1': 0.35; '-0700,': 0.35; "d'aprano": 0.35; 'reply-to:addr:python.org': 0.35; 'useful': 0.37; 'case': 0.37; 'realize': 0.38; 'subject:: ': 0.38; 'some': 0.38; 'perhaps': 0.39; 'to:addr:python.org': 0.39; 'email addr:yahoo.com': 0.63; 'header:Reply-To:1': 0.72; 'reply-to:no real name:2**0': 0.72 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjEIAFeX6U1UXebj/2dsb2JhbABTl3UyjiB3yluGIQSVPIQxhkE Date: Sat, 04 Jun 2011 03:24:50 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: python-list@python.org Subject: Re: how to avoid leading white spaces References: <9e861b0e-e768-401b-b5ca-190f20830a08@s9g2000yqm.googlegroups.com> <94ph22FrhvU5@mid.individual.net> <4de8eef1$0$29996$c3e8da3$5496439d@news.astraweb.com> <1237a287-10b0-4a2d-ba35-97b5238deda1@n11g2000yqf.googlegroups.com> <4de992d7$0$29996$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <4de992d7$0$29996$c3e8da3$5496439d@news.astraweb.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 24 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1307154367 news.xs4all.nl 49039 [::ffff:82.94.164.166]:41590 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6993 On 04/06/2011 03:05, Steven D'Aprano wrote: > On Fri, 03 Jun 2011 12:29:52 -0700, rurpy@yahoo.com wrote: > >>>> I often find myself changing, for example, a startwith() to a RE when >>>> I realize that the input can contain mixed case >>> >>> Why wouldn't you just normalise the case? >> >> Because some of the text may be case-sensitive. > > Perhaps you misunderstood me. You don't have to throw away the > unnormalised text, merely use the normalized text in the expression you > need. > > Of course, if you include both case-sensitive and insensitive tests in > the same calculation, that's a good candidate for a regex... or at least > it would be if regexes supported that :) > [snip] Some regex implementations support scoped case sensitivity. :-) I have at times thought that it would be useful if .startswith offered the option of case insensitivity and there were also str.equal which offered it.