what's wrong with "lambda x : print x/60,x%60"

rurpy at yahoo.com rurpy at yahoo.com
Mon Dec 5 17:59:10 EST 2005


"Gary Herron" <gherron at islandtraining.com> wrote in message
news:mailman.1600.1133766805.18701.python-list at python.org...
> --snip--
> So just use a def.  It is constantly pointed out on
> this list that the lambda provides no extra expressive power, it is
> merely a shortcut

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.  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.

>  and, as you just found out, a rather restrictive one
> at that.

In part because Python's designers failed to make "print" a function
or provide an if-then-else expression.

> --snip--




More information about the Python-list mailing list