<div dir="ltr"><blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<div bgcolor="#FFFFFF" text="#000000">
My objections to this are twofold:<br>
<br>
1) It looks a lot like a lot of other 'structures' in python.
It looks very much like a generator expression or a tuple, so it
isn't immediately obvious to me what you are intending (if this was
allowed syntax of course.)<br></div></blockquote><div><br></div><div>I rarely find myself wondering if something is a function call or a tuple or a generator expression or just an expression within '()' to promote order of operations. I don't see why this use case would all of a sudden make visual parsing all that more difficult, especially when there are often obvious context hints leading up to a lambda expression:<br></div><div><br></div><div class="prettyprint" style="border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code class="prettyprint"><div class="subprettyprint"><span style="color: #000;" class="styled-by-prettify">most_distant_word </span><span style="color: #660;" class="styled-by-prettify">=</span><span style="color: #000;" class="styled-by-prettify"> max</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify">words</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> key</span><span style="color: #660;" class="styled-by-prettify">=(</span><span style="color: #000;" class="styled-by-prettify">edit_distance</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify">word</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #080;" class="styled-by-prettify">"hello"</span><span style="color: #660;" class="styled-by-prettify">)</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #008;" class="styled-by-prettify">from</span><span style="color: #000;" class="styled-by-prettify"> word</span><span style="color: #660;" class="styled-by-prettify">))</span><span style="color: #000;" class="styled-by-prettify"><br><br><br>distant_words </span><span style="color: #660;" class="styled-by-prettify">=</span><span style="color: #000;" class="styled-by-prettify"> filter</span><span style="color: #660;" class="styled-by-prettify">((</span><span style="color: #000;" class="styled-by-prettify">edit_distance</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify">word</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> most_distant_word</span><span style="color: #660;" class="styled-by-prettify">)</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify"><</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #066;" class="styled-by-prettify">5</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #008;" class="styled-by-prettify">from</span><span style="color: #000;" class="styled-by-prettify"> word</span><span style="color: #660;" class="styled-by-prettify">),</span><span style="color: #000;" class="styled-by-prettify"> words</span><span style="color: #660;" class="styled-by-prettify">)</span><span style="color: #000;" class="styled-by-prettify"><br><br><br>shortest_distant_word </span><span style="color: #660;" class="styled-by-prettify">=</span><span style="color: #000;" class="styled-by-prettify"> min</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify">distant_words</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> key</span><span style="color: #660;" class="styled-by-prettify">=(</span><span style="color: #000;" class="styled-by-prettify">len</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify">word</span><span style="color: #660;" class="styled-by-prettify">.</span><span style="color: #000;" class="styled-by-prettify">strip</span><span style="color: #660;" class="styled-by-prettify">())</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #008;" class="styled-by-prettify">from</span><span style="color: #000;" class="styled-by-prettify"> word</span><span style="color: #660;" class="styled-by-prettify">))</span></div></code></div><div><br></div><div>lambda statements tend to be most expressive when used in an expected context (like as the 'key' argument to the sorted function or as the first argument to the filter function.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div bgcolor="#FFFFFF" text="#000000">
2) While it is nice to type that over `lambda :`, typing lambda
is no great burden, and that is already just sugar for a regular def
statement. I don't think there is much of a great need for even
more terse ways of writing an anonymous function, especially ones
with the restrictions that python currently places on them (no
statements). It just doesn't make a lot of sense to change the
syntax at this point. But I think you knew that.<br></div></blockquote><div><br></div><div>Typing 'lambda' is not at all my concern, in fact `(x+1 from x)` takes the same number of keystrokes as `lambda x:x+1`. My complaint is in readability which is supposed to be Python's strong suit. To most people, 'lambda' is pretty much a nonsense word. It might as well be 'quaple'. Would you be ok with writing:</div><div> </div><div class="prettyprint" style="border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code class="prettyprint"><div class="subprettyprint"><span style="color: #000;" class="styled-by-prettify">sorted</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify">words</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> key</span><span style="color: #660;" class="styled-by-prettify">=</span><span style="color: #000;" class="styled-by-prettify">quaple word</span><span style="color: #660;" class="styled-by-prettify">:</span><span style="color: #000;" class="styled-by-prettify"> edit_distance</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify">word</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #080;" class="styled-by-prettify">"hello"</span><span style="color: #660;" class="styled-by-prettify">))</span></div></code></div><div><br></div><div>or would you rather write:</div><div><br></div><div><div class="prettyprint" style="border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code class="prettyprint"><div class="subprettyprint"><span style="color: #000;" class="styled-by-prettify">sorted</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify">words</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> key</span><span style="color: #660;" class="styled-by-prettify">=(</span><span style="color: #000;" class="styled-by-prettify">edit_distance</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify">word</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #080;" class="styled-by-prettify">"hello"</span><span style="color: #660;" class="styled-by-prettify">)</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #008;" class="styled-by-prettify">from</span><span style="color: #000;" class="styled-by-prettify"> word</span><span style="color: #660;" class="styled-by-prettify">))</span></div></code></div></div><div><br></div><div>Most Python constructs are elegantly readable:</div><div><br></div><div class="prettyprint" style="border: 1px solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"><code class="prettyprint"><div class="subprettyprint"><span style="color: #008;" class="styled-by-prettify">with</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #008;" class="styled-by-prettify">lock</span><span style="color: #660;" class="styled-by-prettify">:</span><span style="color: #000;" class="styled-by-prettify"><br> mutate_shared_data</span><span style="color: #660;" class="styled-by-prettify">()</span><span style="color: #000;" class="styled-by-prettify"><br><br><br></span><span style="color: #008;" class="styled-by-prettify">if</span><span style="color: #000;" class="styled-by-prettify"> any</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify">thing</span><span style="color: #660;" class="styled-by-prettify">.</span><span style="color: #000;" class="styled-by-prettify">is_metal </span><span style="color: #008;" class="styled-by-prettify">for</span><span style="color: #000;" class="styled-by-prettify"> thing </span><span style="color: #008;" class="styled-by-prettify">in</span><span style="color: #000;" class="styled-by-prettify"> pockets</span><span style="color: #660;" class="styled-by-prettify">):</span><span style="color: #000;" class="styled-by-prettify"> alarm</span><span style="color: #660;" class="styled-by-prettify">.</span><span style="color: #000;" class="styled-by-prettify">sound</span><span style="color: #660;" class="styled-by-prettify">()</span></div></code></div><div><br></div><div>You can write code that doesn't look like a mess of obscure symbols and esoteric words *except* for lambda expressions.</div></div>