<div dir="ltr">We're not going to break every version of Python since 0.9 because Javascript does something a certain way.  Whatever might be better abstractly, this is well established.<div><br></div><div>As to adding a `.map()` method to *every* iterable... just how would you propose to do that given that it's really easy and common to write custom iterables.  How do you propose to change every class ever written by users? (including ones that already define `.map()` with some other meaning than the one you suggest)?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 13, 2017 at 8:09 AM, Jason H <span dir="ltr"><<a href="mailto:jhihn@gmx.com" target="_blank">jhihn@gmx.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The format of map seems off. Coming from JS, all the functions come second. I think this approach is superior.<br>
<br>
Currently:<br>
map(lambda x: chr(ord('a')+x), range(26)) # ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']<br>
<br>
But I think this reads better:<br>
map(range(26), lambda x: chr(ord('a')+x))<br>
<br>
Currently that results in:<br>
TypeError: argument 2 to map() must support iteration<br>
<br>
Also, how are we to tell what supports map()?<br>
Any iterable should be able to map via:<br>
range(26).map(lambda x: chr(ord('a')+x)))<br>
<br>
While the line length is the same, I think the latter is much more readable, and the member method avoids parameter order confusion<br>
<br>
For the global map(),<br>
having the iterable first also increases reliability because the lambda function is highly variable in length, where as parameter names are generally shorter than even the longest lambda expression.<br>
<br>
More readable: IMHO:<br>
map(in, lambda x: chr(ord('a')+x))<br>
out = map(out, lambda x: chr(ord('a')+x))<br>
out = map(out, lambda x: chr(ord('a')+x))<br>
<br>
Less readable (I have to parse the lambda):<br>
map(lambda x: chr(ord('a')+x), in)<br>
out = map(lambda x: chr(ord('a')+x), out)<br>
out = map(lambda x: chr(ord('a')+x), out)<br>
<br>
But I contend:<br>
range(26).map(lambda x: chr(ord('a')+x)))<br>
is superior to all.<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons.  Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div>
</div>