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

Mohammad Jeffry linuxlah at gmail.com
Mon Dec 5 07:30:35 CET 2005

Dear All,

Can't a lambda uses the input parameter more then once in the lambda body?
lambda x : print x/60,x%60

I tried with def and it works but got syntax error with lambda. Below is an
interactive sample:

linuxlah at algorhythm ~ $ python
Python 2.4.2 (#1, Nov 18 2005, 19:32:15)
[GCC 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def func_hrs(x): print x/60,x%60
>>> func_hrs(400)
6 40
>>> lambda_hrs = lambda x : print x/60,x%60
  File "<stdin>", line 1
    lambda_hrs = lambda x : print x/60,x%60
SyntaxError: invalid syntax

My main concern is how can I do this in lambda?

And whoever does an atom's weight of evil will see it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051205/cf94aea2/attachment.html>

More information about the Python-list mailing list