how to avoid leading white spaces

MRAB python at mrabarnett.plus.com
Fri Jun 3 22:24:50 EDT 2011


On 04/06/2011 03:05, Steven D'Aprano wrote:
> On Fri, 03 Jun 2011 12:29:52 -0700, rurpy at 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.



More information about the Python-list mailing list