<div dir="ltr">> Why is it ','.join(iterable), why isn't there join(',', iterable)<div><br></div><div>Because join apply on a string, and strings are defined by the str class, not by a specific protocol (unlike iterables).</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-09-14 18:43 GMT+02:00 MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com" target="_blank">python@mrabarnett.plus.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 2017-09-14 03:55, Steven D'Aprano wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On Wed, Sep 13, 2017 at 11:05:26PM +0200, Jason H wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> And look, map() even works with all of them, without inheritance,<br>
> registration, and whatnot. It's so easy!<br>
<br>
Define easy. <br>
</blockquote>
<br>
Opposite of hard or difficult.<br>
<br>
You want to map a function?<br>
<br>
map(function, values)<br>
<br>
is all it takes. You don't have to care whether the collection of values<br>
supports the map() method, or whether the class calls it "apply", or<br>
"Map", or something else. All you need care about is that the individual<br>
items inside the iterable are valid for the function, but you would need<br>
to do that regardless of how you call it.<br>
<br>
[1, 2, 3, {}, 5].map(plusone)  # will fail<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It's far easier for me to do a dir(dict) and see what I can do with it.<br>
</blockquote>
<br>
And what of the functions that dict doesn't know about?<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 This is what python does after all. "Does it have the interface I expect?" Global functions like len(), min(), max(), map(), etc(), don't really tell me the full story. len(7) makes no sense. I can attempt to call a function with an invalid argument.<br>
</blockquote>
<br>
And you can attempt to call a non-existent method:<br>
<br>
x = 7<br>
x.len()<br>
<br>
Or should that be length() or size() or count() or what?<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
[].len() makes more sense.<br>
</blockquote>
<br>
Why? Getting the length of a sequence or iterator is not specifically a<br>
list operation, it is a generic operation that can apply to many<br>
different kinds of things.<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Python is weird in that there are these special magical globals <br>
</blockquote>
<br>
The word you want is "function".<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
that operate on many things.<br>
</blockquote>
<br>
What makes that weird? Even Javascript has functions. So do C, Pascal,<br>
Haskell, C++, Lisp, Scheme, and thousands of other languages.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Why is it ','.join(iterable), why isn't there join(',', iterable) At what point does a method become a global? A member? Do we take the path that everything is a global? Or should all methods be members? So far it seems arbitrary.<br>
</blockquote>
<br>
Okay, its arbitrary.<br>
<br>
Why is it called [].len instead of [].length or {}.size? Why None<br>
instead of nil or null or nul or NULL or NOTHING?<br>
<br>
Many decisions in programming languages are arbitrary.<br>
<br>
</blockquote></div></div>
In Java, strings have .length(), arrays have .length, and collections have .size().<div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofco<wbr>nduct/</a><br>
</div></div></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>