En Mon, 31 Aug 2009 04:41:57 -0300, Pierre <pierre.gaill...@gmail.com>
escribió:
I would like to know if it is possible to define a loop in a lambda
function....
How to manage the indents ? Example :
s_minus_1 = lambda s : for index in range(0, len(s)) : s[index] = s
[index]-1
You can't. lambda is just a way to define a short, inline, anonymous
function, and its body can only contain expressions, not statements.
Even if what you want were legal, giving a name to the resulting
expression kind of defeats the purpose of lambda - use a normal function
instead:
def s_minus_1(s):
"document usage here"
for index,item in enumerate(s):
s[index] -= 1
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list