> Alex Shafer via Python-ideas wrote: >> 1) I'm in favor of adding a stringify method to all collections > > Are you volunteering to update all the collection > classes in the world written in Python? :-)
To be fair, we could add an implementation to the sequence ABC, and get pretty far. Not that I’m suggesting that — as I said earlier, Python is all about iterables, not sequences, anyway. Also, despite some folks’ instance that this “stringify’ method is something many folks want -.I’m not even sure what it is. I was thinking it was: def stringify(self, sep): return sep.join(str(i) for i in self) Which, by the way would work for any iterable :-) If you want a language designed specifically for text processing, use Perl. Python is deliberately strongly typed, so that: 2 + “2” Raises an error. Why should: “”.join([2, “2”]) not raise an error as well? And aside from repr or ascii, when I turn numbers into text, I usually want to control the formatting anyway: “ “.join(f”{n:.2f}” for n in seq) So having str() called automatically for a join wouldn’t be that useful. -CHB _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/