<div dir="auto"><div><div class="gmail_quote"><div dir="ltr">Op do 23 aug. 2018 09:06 schreef Jacco van Dorp <<a href="mailto:j.van.dorp@deonet.nl">j.van.dorp@deonet.nl</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think it would have been better to use def from the start instead of lambda. The only thing JS does right is using the same "function" keyword for both of these.</div></blockquote></div></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto">Seriously?</div><div dir="auto"><br></div><div dir="auto">Consider how the following code</div><div dir="auto"><br></div><div dir="auto">function f() { return 42; }</div><div dir="auto"><br></div><div dir="auto">may or may not bind the function to f, depending on if it appears in expression or statement context. Just Google and find all the newbies who get confused about this.</div><div dir="auto"><br></div><div dir="auto">And the proposed def syntax is almost as terrible:</div><div dir="auto"><br></div><div dir="auto">def greet: print("hello'')</div><div dir="auto"><br></div><div dir="auto">This would then be legal, and leave the newbie confused why greet remains undefined.</div><div dir="auto"><br></div><div dir="auto">Please don't repurpose def.</div><div dir="auto">Repurposing for and if inside comprehensions is already confusing to newbies.</div><div dir="auto"><br></div><div dir="auto">Stephan</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>However, changing it now doesn't seem that important to me. </div><div><br></div><div>(And I've used lambda's as default argument - I was moving data from one database to another, and wanted a generic method to switch out column names that defaulted to the same header. So it became a lambda x:x function by default, but you can provide any function that takes and returns a string and change the column names. This was last week.)</div><div><br></div><div>And lets be real - adding a new keyword is something to be done extremely sparingly. lambda could have been avoided by re-using def. And no, it being the same keyword is an advantage, as they do the exact same - they create a function. It's the same reason as we use if condition: </div></div>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank" rel="noreferrer">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div></div></div>