[Tutor] Can't use builtin function objects like user defined objects

Gerrit Holl gerrit@nl.linux.org
Fri, 3 Mar 2000 16:34:17 +0100


<quote name="Emile van Sebille" date="952060795" email="emile@fenx.com">
> As a follow up then, why doesn't this work:
> 
> >>> testtext = ['Four', 'lines', 'of', 'text.']
> >>> map(lambda x: x, testtext)
> ['Four', 'lines', 'of', 'text.']
> >>> map(lambda x: print x, testtext)
> SyntaxError: invalid syntax

Lambda's have an extremely strange syntax; you can't use statements
from within lambda's. Try:

>>> map(lambda x: sys.stdout.write(x), testtext)

instead.

</quote>

Hope that helps!

regards,
Gerrit.

-- 
Plies korekt enie bet ingglisj joe encauntur in mai imil mesusj!
-----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com
Version: 3.12
GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE?
Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y
-----END GEEK CODE BLOCK-----