<div dir="ltr">One reason I think this is confusing is that "list.join(sep)" is how basically everyone else does it, including: Ruby, Javascript, Scala, Guava-Java (normal java doesn't have anything). People who don't do it this way include C# (static method), Boost-C++ (static method), PHP (static method)<br>
<div><br></div><div>Nobody does it the Python way AFAICT. </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Aug 11, 2014 at 10:45 AM, Stephen Hansen <span dir="ltr"><<a href="mailto:me+python@ixokai.io" target="_blank">me+python@ixokai.io</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div class="">On Mon, Aug 11, 2014 at 10:10 AM, Haoyi Li <span dir="ltr"><<a href="mailto:haoyi.sg@gmail.com" target="_blank">haoyi.sg@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><p dir="ltr">> In fact, it makes very logical sense once you explain it and makes people think of things more Pythonically after. I say from experience, not in theory.</p>
</div><p dir="ltr">Could you elaborate about "making people think more pythonically after" bit? I can see how explaining the API makes people understand the API, but I'm curious how it makes people behave differently after.<br>
</p></blockquote><div><br></div></div><div>Well, its an opinion of course, so it may be as useful as the thought that the sky is high. It doesn't make people behave differently, but it does lead them to writing idiomatic code. There's naive Python code, which ideally should be clear and easy still, and then there's idiomatic Python code which has a beauty in its expressiveness while also being (relatively) efficient.</div>
<div><br></div><div>But, if the opposite of "string.split(sep)" were "list_of_strings.join(sep)" then that would mean that List would have to know about how to combine strings. That's not very Pythonic. Also, Strings are immutable, that means:</div>
<div><br></div><div>str1 = str1 + str2</div><div><br></div><div>logically leads one to assume that it is constructing an entirely new string, copying the contents of str1 and str2 into it, and discarding the original str1. In fact, it did that for a long time. You can't change strings, after all. That is an fundamental tenet, and when people learn that they will get a new tool and think closer to idiomatic Python. Now, CPython has an optimization for this case which is the only reason the idea of sum(list_of_strings) is not largely fundamentally broken, but that's not a promise and not a feature of the language.</div>
<div><br></div><div>IMHO.</div><div><br></div></div></div></div>
</blockquote></div><br></div>