[Python-ideas] string codes & substring equality
Ethan Furman
ethan at stoneleaf.us
Thu Nov 28 05:09:50 CET 2013
On 11/27/2013 08:02 PM, Chris Angelico wrote:
> On Thu, Nov 28, 2013 at 10:52 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
>> On 11/27/2013 03:30 PM, Chris Angelico wrote:
>>>
>>>
>>> Am I going to check help("".upper) to see if it can
>>> also convert digits to superscript?
>>
>>
>> Heh, that would be cool.
>>
>> I retract (most of) my comment. start(end)swith is certainly not an obvious
>> name for something that can also do random substring comparisons.
>>
>> Personally, I do search the docs when looking for functionality I don't know
>> about. As there is no obvious substring method I would check the docs for
>> all the string methods to see if any of them had any thing close to, or
>> exactly, what I needed.
>>
>> But, hey, maybe that's just me. :)
>
> Yeah, that would be one good way to do it. But do you need a
> "substring comparison" method, or do you simply extract a substring
> and compare it (which is done with slicing)? Sometimes you don't need
> a single named way to do exactly what you want[1], you should just
> build from primitives.
Which is what I would start with. I wouldn't worry about the rest unless I was curious, or had profiled and knew there
was a performance issue.
--
~Ethan~
More information about the Python-ideas
mailing list