print statement in lambda expression
Gerson Kurz
gerson.kurz at t-online.de
Sat Feb 2 23:08:49 EST 2002
More information about the Python-list mailing list
Sat Feb 2 23:08:49 EST 2002
- Previous message (by thread): Enhanced Generators - reiterating over a file
- Next message (by thread): print statement in lambda expression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, 03 Feb 2002 03:14:53 GMT, "Michael P. Soulier" <msoulier at mcss.mcmaster.ca_.nospam> wrote: > Hello people. > > I just recently found that I couldn't put a print statement in a lambda >expression as a binding in Tk. Could someone explain why? The reason was explained already by other people, here is a hack that makes it work nonetheless: use sys.stdout.write; e.g. import sys lambda x,y: return sys.stdout.write("...") if you need multiple args, make a varargs output function: def out(*x): print " ".join(map(str,x)) f = lambda x,y: out(x,y) f("Hello", 42)
- Previous message (by thread): Enhanced Generators - reiterating over a file
- Next message (by thread): print statement in lambda expression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list