The difference in readability between

func = lambda x: x**3 - 5*x

def func(x):
    return x**3 - 5*x

def func(x): return x**3 - 5*x

is obviously a matter of personal vision.

The fuctional difference (and, I believe, the only difference) is that the 
def form attaches the specific name 'func' to the function object as its 
func_name attribute while the lambda form attaches the generic 'name' 
'<lambda>'.   This makes tracebacks, for instance, less informative.

The reason some think the name=lambda form an abuse is that it is a second 
way to do almost the same thing (with the functional difference being a 
negative) while ignoring the intended purpose of lambda's presence in the 
language.  (But I will not argue this either way.)

Terry J. Reedy





-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to