<div dir="ltr">For these examples, you shouldn't be using map at all.<br><br>On Wednesday, September 13, 2017 at 11:10:39 AM UTC-4, Jason H wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 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></blockquote><div><br></div><div>out = (chr(ord('a')+x) for x in out)</div><div><br></div><div>is the most legible.</div><div> </div><blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">out = map(out, lambda x: chr(ord('a')+x))  </blockquote><blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<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="javascript:" target="_blank" gdf-obfuscated-mailto="aHiD5fg2AgAJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">Python...@python.org</a>
<br><a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fpython-ideas\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFj1EaNHnVmh20FnFPoUi4J-MpfQw';return true;" onclick="this.href='https://www.google.com/url?q\x3dhttps%3A%2F%2Fmail.python.org%2Fmailman%2Flistinfo%2Fpython-ideas\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFj1EaNHnVmh20FnFPoUi4J-MpfQw';return true;">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a>
<br>Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fpython.org%2Fpsf%2Fcodeofconduct%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHJOrArSUDKkjrnthO6_CznMzkPsA';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Fpython.org%2Fpsf%2Fcodeofconduct%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHJOrArSUDKkjrnthO6_CznMzkPsA';return true;">http://python.org/psf/<wbr>codeofconduct/</a>
<br></blockquote></div>