__fromiter__, anyone?<br><br><div>On Sat Jan 04 2014 at 3:31:59 PM, Masklinn <<a href="mailto:masklinn@masklinn.net">masklinn@masklinn.net</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 2014-01-04, at 23:59 , Steven D'Aprano <<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>> wrote:<br>
> On Sat, Jan 04, 2014 at 11:22:16AM +0100, spir wrote:<br>
>> On 01/03/2014 07:11 PM, Bruce Leban wrote:<br>
>>> As to the idea of making strings not iterable, that would break my code. I<br>
>>> write a lot of code to manipulate words (to create puzzles) and iterating<br>
>>> over strings is fundamental. In fact, I'd like to have strings as results<br>
>>> of iteration operations on strings:<br>
>>><br>
>>>>>>>>> sorted('string')<br>
>>> 'ginrst'<br>
>>>>>>>>> list(itertools.permutations('<u></u>bar'))<br>
>>> ['bar', 'bra', 'abr', 'arb', 'rba', 'rab']<br>
><br>
> That would be nice to have.<br>
<br>
More generally, it would be nice if a sequence type could specify how to<br>
derive a new instance of itself (from an iterable for instance).<br>
Constructors don't necessarily work (e.g. str's constructor). Clojure<br>
has such a concept through the IPersistentCollection protocol:<br>
empty(coll) creates a new (empty) instance of coll (clojure's<br>
collections being immutable, it makes sense to create an empty<br>
collection then add stuff into it via into() or conj())<br>
<br>
______________________________<u></u>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/<u></u>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/<u></u>codeofconduct/</a><br>
</blockquote>