As far as "one line" is concerned, it's a complete red herring, because
def func(x): whatever
is no worse of a line than
func = lambda x: whatever
. The
def
is actually shorter. The only problem is when it doesn't follow some style guide imposed by a text editor or a code reviewer who is impervious to reason, but "my colleagues are horse's asses and I can't work my text editor", while perhaps an insurmountable problem, is only a weak justification for preferring one code construct over another. The real reason is that
def
is not an expression. —
Steve Jessop 54 secs ago