[Python-ideas] discontinue iterable strings

Michael Selik michael.selik at gmail.com
Sat Aug 20 08:31:48 EDT 2016


On Sat, Aug 20, 2016 at 3:48 AM Chris Angelico <rosuav at gmail.com> wrote:

> On Sat, Aug 20, 2016 at 4:28 PM, Alexander Heger <python at 2sn.net> wrote:
> > Yes, I am aware it will cause a lot of backward incompatibilities...
>
> Tell me, would you retain the ability to subscript a string to get its
> characters?
>
> >>> "asdf"[0]
> 'a'
>

A separate character type would solve that issue. While Alexander Heger was
advocating for a "monolithic object," and may in fact not want
subscripting, I think he's more frustrated by the fact that iterating over
a string gives other strings. If instead a 1-length string were a
different, non-iterable type, that might avoid some problems.

However, special-casing a character as a different type would bring its own
problems. Note the annoyance of iterating over bytes and getting integers.

In case it's not clear, I should add that I disagree with this proposal and
do not want any change to strings.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160820/c5cedc17/attachment.html>


More information about the Python-ideas mailing list