I'm going to respond to a few replies with this one. > > Because join apply on a string, and strings are defined by the str class, > > not by a specific protocol (unlike iterables). > > Join actually used to only be available as a function (string.join in > Python 2.x). However, nobody could ever remember whether the parameter > order was "join this series of strings with this separator" or "use > this separator to join this series of strings" - it didn't have the > same kind of natural ordering that map and filter did thanks to the > old "apply" builtin ("apply this function to these arguments" - while > the apply builtin itself is no longer around, the "callable(*args, > **kwds)" ordering that corresponds to the map() and filter() argument > ordering lives on). > > This meant that when string.join became a builtin interface, it became > a string method since: > > 1. Strings are one of the few Python APIs that *aren't* protocol > centric - they're so heavily intertwined with the interpreter > implementation, that most folks don't even try to emulate or even > subclass them*. > 2. As a string method, it's obvious what the right order has to be > (separator first, since it's the separator that has the method)
Your second point is aligned with my initial point. Providing it as a class method further removes the ambiguity of what the right order is because of there is only one parameter: the function. As for the comment about Python being better designed, I never implied it wasn't. Python is my favorite. However as someone who uses multiple languages, and JS has risen in popularity, and it's not going anywhere, I seek a more peaceful co-existence with this language - a language that was designed in 10 days in 1995. In a covert way, by embracing some of the not-too-terrible syntax you make it easier for JS programmers to feel at home in Python, and adopt it. I see this only has promoting a peaceful coexistence. Another pain point is python uses [].append() and JS uses [].join() Having a wrapper for append would be helpful. And for that matter, why isn't append/extend a global? I can add things to lots of different collections. lists, sets, strings... _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/