On 6/24/05, Xavier Décoret <[EMAIL PROTECTED]> wrote: > > For example, the code > > # f = lambda : print "hello" > # f() > does not compile, although: > > # def f(): > # print "hello" > # f() > > does compile. Is there a particular syntax for lambda that I am missing > or is it simply limited and I cannot do what I want with lambda.
lambda calls can only include functions; print is a statement, not a function. Try this instead: import sys f = lambda : sys.stdout.writelines("Hello") f() However, if you're going to be binding the function to a name, there is no need to use lambda at all; just def a function and be done with it. > In the same spirit, how can I do to compute intermediary values in the > body of a lambda function. Let's say (dummy example): I leave this to someone more expert than I. -- Kristian kristian.zoerhoff(AT)gmail.com zoerhoff(AT)freeshell.org -- http://mail.python.org/mailman/listinfo/python-list