Op do 23 aug. 2018 09:06 schreef Jacco van Dorp <j.van.d...@deonet.nl>:
> 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. > Seriously? Consider how the following code function f() { return 42; } 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. And the proposed def syntax is almost as terrible: def greet: print("hello'') This would then be legal, and leave the newbie confused why greet remains undefined. Please don't repurpose def. Repurposing for and if inside comprehensions is already confusing to newbies. Stephan > > However, changing it now doesn't seem that important to me. > > (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.) > > 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: > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/