Message193195
Is the scope of this issue just what is in the title, the whole PEP, or something in between;-?
For instance, Guido once approved (on pydev) adding an admonition to Programming Recommendations something like the following.
* Use a def statement instead of an assignment with a lambda expression.
Yes:
def f(x): return 2*x
No:
f = lambda s: 2*x
The (only) difference between these is that the name attribute of the resulting function object is specifically 'f' instead of the generic '<lambda>'. This is more useful for tracebacks and string representations in general.
The entry could point out that a separate statement that binds the function to a name negates the two reasons that justify using lambda, but that is probably unnecessary.
This is from a discussion at least 2 years ago, perhaps 3 or more, before I would have been comfortable or perhaps even eligible to push a patch, and no one else picked up on it either. |
|
Date |
User |
Action |
Args |
2013-07-16 22:23:47 | terry.reedy | set | recipients:
+ terry.reedy, barry, ncoghlan |
2013-07-16 22:23:47 | terry.reedy | set | messageid: <1374013427.5.0.0507027276305.issue18472@psf.upfronthosting.co.za> |
2013-07-16 22:23:47 | terry.reedy | link | issue18472 messages |
2013-07-16 22:23:47 | terry.reedy | create | |
|