On Mon, 31 Aug 2009 08:41:57 +0100, Pierre <pierre.gaill...@gmail.com>
wrote:
Hello,
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 use commands in a lambda function, only expressions. The nearest
thing I can think of to what you want here is to use a list comprehension:
s_minus_1 = lambda s : [i-1 for i in s]
my_list = s_minus_1(my_list)
On the other hand, giving a name to an anonymous function rather defeats
the point of it being an *anonymous* function! What are you actually
trying to do here? There's almost certainly a better way to do it than
this.
--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list