[Python-ideas] string codes & substring equality

spir denis.spir at gmail.com
Fri Nov 29 07:42:44 CET 2013


On 11/29/2013 05:57 AM, Greg Ewing wrote:
> Steven D'Aprano wrote:
>> On Thu, Nov 28, 2013 at 12:43:05PM +0100, spir wrote:
>>
>>> Is it weird to consider a .code(i) string method?
>>
>> Such a method should not be called "code", since "ordinal" or "ord" is the
>> accepted term for it.
>
> How about giving ord() an optional index parameter?
>
>     ord(s, i)
>
> would be equivalent to
>
>     ord(s[i])
>
> but would avoid creating an intermediate string
> object.

Very well, for me. Does the job as needed.
(But then, possibly, some would wonder why this new ord(s,i) is not a string 
method ;-)

Denis


More information about the Python-ideas mailing list