[Python-ideas] string codes & substring equality
Terry Reedy
tjreedy at udel.edu
Thu Nov 28 00:59:17 CET 2013
On 11/27/2013 6:30 PM, Chris Angelico wrote:
> On Thu, Nov 28, 2013 at 9:28 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
>> On 11/27/2013 01:34 PM, spir wrote:
>>>
>>> On 11/27/2013 09:01 PM, Paul Moore wrote:
>>>>
>>>> On 27 November 2013 17:59, MRAB <python at mrabarnett.plus.com> wrote:
>>>>>
>>>>>
>>>>> --> help(str.startswith)
>>>>>
>>>>> Help on method_descriptor:
>>>>>
>>>>> startswith(...)
>>>>> S.startswith(prefix[, start[, end]]) -> bool
>>>>
>>>>
>>>> Wow! I never knew that startswith/endswith accepted start and end
>>>> arguments. Something new I learned today - thanks :-)
>>>
>>>
>>> You're not the only one ;-) I learnt it yesterday. Probably the method
>>> name misleads (not only you and i?.
>>
>>
>> What's misleading about it? And how hard is it to look it up in the docs
>> (or help)? That's what I do when I'm going to use something I haven't
>> before.
>
> If I want to know if this bit of this string matches that bit of that
> string, I'm not going to look at startswith, unless I already know
> that it has this functionality - which until today I didn't. When
> would I go to look it up in the docs? Am I going to check
> help("".upper) to see if it can also convert digits to superscript?
I have occasionally recommended on Python list that beginners read
through the beginning chapters of the Library Reference, on builtins,
just to see what is available. After several years, a refresher read
would be helpful. Presuming that I once read the .start(end)swith
signature, I had forgotten about the two params also.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list