[Python-ideas] str.startswith taking any iterator instead of just tuple
Terry Reedy
tjreedy at udel.edu
Tue Jan 7 00:39:10 CET 2014
On 1/6/2014 3:09 AM, Devin Jeanpierre wrote:
> On Sun, Jan 5, 2014 at 9:08 PM, Terry Reedy <tjreedy at udel.edu> wrote:
>>> On Jan 5, 2014, at 3:09, David Townshend
>>> <aquavitae69 at gmail.com> wrote:
>>>
>>>> Reading this thread made me start to think about why a string is a
>>>> sequence,
>>
>>
>> Because a string is defined in math/language theory as a sequence of symbols
>> from an alphabet. If you want to invent or define something else, such as an
>> atomic symbol type, please use a different term. For example:
>
> And sequences in math / CS are functions from the natural
> numbers to elements of the sequence.
And functions (mappings) in math are defined either by a rule for
calculating the output from the input or by a table (set of pairs)
giving the output for each input. If the input domain is the finite
sequence of counts from 0 to k, the table can be condensed to a sequence
of k+1 output values.
> Since isinstance(str, types.FunctionType) isn't True,
Python has multiple builtin callable types, and users can define more,
so you need to expand that test. Anyway, since a string is not a
function defined by rule, it must be a function defined by a table.
Since the input domain is a finite sequence of counts, we can and do
condense the table to a sequence of output values. Which is an expansion
of what I said.
> [snip]
--
Terry Jan Reedy
More information about the Python-ideas
mailing list