On Sun, Oct 27, 2019 at 11:43 PM Steven D'Aprano <st...@pearwood.info> wrote:
>
> On Sun, Oct 27, 2019 at 12:10:22AM -0700, Andrew Barnert via Python-ideas 
> wrote:
>
> > If you redesign your find, re.search, etc. APIs to not return
> > character indexes, then I think you can get away with not having
> > character-indexable strings.
>
> If string.index(c) doesn't return the index of c in string, then what
> does it return?
>
> I think you are conflating the public API based on characters (to be
> precise: code points) for some underlying implementation based on bytes.
> Given zero-based indexing, and the string:
>
>     "abÇÐεф"
>
> the index of "ф" better damn well be 5 rather than 8 (UTF-8), 10
> (UTF-16) or 20 (UTF-32) or I'll be knocking on the API designer's door
> with a pitchfork and a flaming torch *wink*
>
> And returning <AbstractIndex object at 0xb7ce1bf0> is even worse.
>

And in response to the notion that you don't actually need the index,
just a position marker... consider this:

  File "/home/rosuav/tmp/demo.py", line 1
    print("Hello, world!')
                         ^
SyntaxError: EOL while scanning string literal

Well, either that, or we need to make it so that " "*<AbstractIndex
object at 0xb7ce1bf0> results in the correct number of spaces to
indent it to that position. That ought to bring in plenty of
pitchforks...

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/U2Z574GFGT6GIMS737WQO3QLFPEQZXIN/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to