Friday 29 April 2005 00:06 am Paul Rubin wrote: > Closest you can come is: > > f = lambda: sys.stdout.write("hello world\n") Ah. :)) Why does the "print" statement return a syntax error here?
>>> lambda: print("hallo") File "<stdin>", line 1 lambda: print("hallo") ^ SyntaxError: invalid syntax > Of course if you're trying to capture the function in a named variable > like f, just use a def statement. Unfortunately I want to assign a handler function to an object and something like this does not work: >>> class Foobar(object): pass ... >>> a = Foobar() >>> def a.handler(): File "<stdin>", line 1 def a.handler(): ^ SyntaxError: invalid syntax But wrapping print into a myprint function works :) Thanks, Ciao Uwe -- http://mail.python.org/mailman/listinfo/python-list