<story><title>The PEPs of Python 3.9</title><url>https://lwn.net/Articles/819853/</url></story><parent_chain><item><author>tln</author><text>Sometimes I wish that python strings weren&amp;#x27;t directly iterable...&lt;p&gt;this article sums it up better than I ever could &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.xanthir.com&amp;#x2F;b4wJ1&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.xanthir.com&amp;#x2F;b4wJ1&lt;/a&gt;&lt;p&gt;...then str.strip and variants could be cleanly and logically extended to allow this functionality, because passing a string and a sequence of strings would be distinguishable.&lt;p&gt;Alas, clean and logical function design can be hard to do late in a languages life.&lt;p&gt;PEP 593 and PEP 585 are clean and logical... glad to see that :)</text></item></parent_chain><comment><author>jorams</author><text>I agree with most of the article you link, but there&amp;#x27;s one thing I don&amp;#x27;t understand: The article quickly dismisses the obvious fix for recursive iterability, to make strings be composed of &amp;quot;characters&amp;quot;:&lt;p&gt;&amp;gt; And an obvious &amp;quot;fix&amp;quot; for this is worse than the original problem: Common Lisp says that strings are composed of characters, a totally different type, which doesn&amp;#x27;t implement the same methods and has to be handled specially. It&amp;#x27;s really annoying.&lt;p&gt;It seems to me this contradicts most of what the article says. Sure, strings are rarely collections, so they should not be iterable by default. But the final solution offered admits that  sometimes they are, and then you want to be able to iterate over &lt;i&gt;something&lt;/i&gt;. For most instances of &lt;i&gt;something&lt;/i&gt;, It does not make sense for the individual &amp;quot;elements&amp;quot; to be strings. Bytes are clearly not strings, code points are clearly not strings, grapheme clusters are clearly not strings. Each of those will provide very different methods, because they are very different things. Only after that point (words, sentences, etc.) does the idea of the element being the same type start making sense again.&lt;p&gt;Clearly the concept of a &amp;quot;character&amp;quot; is too ambiguous, and there is no clear &amp;quot;default&amp;quot; for what it should mean, but the idea of a string consisting of some kind of element that is not string appears obviously correct.</text></comment>
<story><title>The PEPs of Python 3.9</title><url>https://lwn.net/Articles/819853/</url></story><parent_chain><item><author>tln</author><text>Sometimes I wish that python strings weren&amp;#x27;t directly iterable...&lt;p&gt;this article sums it up better than I ever could &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.xanthir.com&amp;#x2F;b4wJ1&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.xanthir.com&amp;#x2F;b4wJ1&lt;/a&gt;&lt;p&gt;...then str.strip and variants could be cleanly and logically extended to allow this functionality, because passing a string and a sequence of strings would be distinguishable.&lt;p&gt;Alas, clean and logical function design can be hard to do late in a languages life.&lt;p&gt;PEP 593 and PEP 585 are clean and logical... glad to see that :)</text></item></parent_chain><comment><author>danpalmer</author><text>Strings being it stable can cause problems, and another commenter has pointed out that Swift handles it well.&lt;p&gt;However I think strings being iterable is one of the core ergonomics in the language and basic types of Python that make it so nice for many applications. Scripting, scraping, data cleanup, data science, even basic web development, all benefit hugely from little features like this. Without this sort of thing Python would be a different language with different uses.&lt;p&gt;While I normally like safety and types, I’m personally happy with things like this because it fits with Pythons strengths.</text></comment>