[Tutor] lambda: print('x') raises SyntaxError?
wcyeee at gmail.com
Thu Jul 5 17:23:04 CEST 2007
Hi. Is there a reason the code below raises a syntax error? It's probably
something silly on my part, but I can't figure it out:
>>> b = lambda: print('bar')
File "<stdin>", line 1
b = lambda: print('bar')
SyntaxError: invalid syntax
This code seems to work fine, so I don't know why the "print" statement in
the above code is wrong.
This works fine too:
>>> import sys
>>> a = lambda: sys.stdout.write('foo\n')
What am I missing? Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor