what's wrong with "lambda x : print x/60,x%60"
Paul Rubin
http
Mon Dec 5 18:42:06 EST 2005
Sybren Stuvel <sybrenUSE at YOURthirdtower.com.imagination> writes:
> > No, it is not merely a shortcut. It often allows one to avoid
> > polluting the namespace with a completely superfluous function name,
> > thus reducing code smell.
>
> Which can also be done by using inner functions.
Inner functions with no names?
> > It can also avoid a multi-line function defintion which often pushes
> > other relevant code off the current page and out of view, and thus
> > lambda can increase program readability.
> def somefunc(x): return x*5
> How is that a multi-line function definition?
def mult_by_five():
def somefunc(x): return x*5
return somefunc
is multi-line, as opposed to:
def mult_by_five(): return lambda x: x*5
More information about the Python-list
mailing list