<div dir="ltr">> And for that matter, why isn't append/extend a global? I can add things to lots of different collections. lists, sets, strings...<div><br></div><div>No, append is relevant when the collection is ordered. You update dictionnaries, you make unions of sets, and you append lists to another ones.<br>These operations are specific for each datatype.</div><div><br></div><div>And not all iterables need operations to append new elements.</div><div>But you can chain generic iterables (with itertools.chain).</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-09-15 16:21 GMT+02:00 Jason H <span dir="ltr"><<a href="mailto:jhihn@gmx.com" target="_blank">jhihn@gmx.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm going to respond to a few replies with this one.<br>
<span class=""><br>
> > Because join apply on a string, and strings are defined by the str class,<br>
> > not by a specific protocol (unlike iterables).<br>
><br>
> Join actually used to only be available as a function (string.join in<br>
> Python 2.x). However, nobody could ever remember whether the parameter<br>
> order was "join this series of strings with this separator" or "use<br>
> this separator to join this series of strings" - it didn't have the<br>
> same kind of natural ordering that map and filter did thanks to the<br>
> old "apply" builtin ("apply this function to these arguments" - while<br>
> the apply builtin itself is no longer around, the "callable(*args,<br>
> **kwds)" ordering that corresponds to the map() and filter() argument<br>
> ordering lives on).<br>
><br>
> This meant that when string.join became a builtin interface, it became<br>
> a string method since:<br>
><br>
> 1. Strings are one of the few Python APIs that *aren't* protocol<br>
> centric - they're so heavily intertwined with the interpreter<br>
> implementation, that most folks don't even try to emulate or even<br>
> subclass them*.<br>
> 2. As a string method, it's obvious what the right order has to be<br>
> (separator first, since it's the separator that has the method)<br>
<br>
</span>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.<br>
<br>
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.<br>
<br>
Another pain point is python uses [].append() and JS uses [].join() Having a wrapper for append would be helpful.<br>
<br>
And for that matter, why isn't append/extend a global? I can add things to lots of different collections. lists, sets, strings...<br>
<br>
<br>
<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Antoine Rozo</div></div>
</div>