without the "print" also gives me error:-

>>> lambda_hrs = lambda x : x/60,x%60
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'x' is not defined


On 12/5/05, Mohammad Jeffry <[EMAIL PROTECTED]> wrote:
Dear All,

Can't a lambda uses the input parameter more then once in the lambda body?
eg:
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:

[EMAIL PROTECTED] ~ $ 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.



--
And whoever does an atom's weight of evil will see it.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to