[Tutor] lambda: print('x') raises SyntaxError?
wc yeee
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.
>>> print('bar')
bar
This works fine too:
>>> import sys
>>> a = lambda: sys.stdout.write('foo\n')
>>> a()
foo
What am I missing? Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070705/06e84473/attachment.htm
More information about the Tutor
mailing list