anonymous function objects?

Paul Rubin http
Thu Apr 28 18:06:56 EDT 2005


Uwe Mayer <merkosh at hadiko.de> writes:
> >>> f = {print "hello world"}
> >>> f()
> hello world

> in Pyton?  Lambda expressions don't work here.

Closest you can come is:

   f = lambda: sys.stdout.write("hello world\n")

Of course if you're trying to capture the function in a named variable
like f, just use a def statement.



More information about the Python-list mailing list