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

Emile van Sebille Emile van Sebille" <emile@fenx.com
Fri, 3 Mar 2000 06:19:55 -0800


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

Emile van Sebille
emile@fenx.com
-------------------


----- Original Message -----
From: Gerrit Holl <gerrit@nl.linux.org>
To: Jason Stokes <jstok@bluedog.apana.org.au>
Cc: <tutor@python.org>
Sent: Friday, March 03, 2000 4:25 AM
Subject: Re: [Tutor] Can't use builtin function objects like user
defined objects


> <quote name="Jason Stokes" date="952100675"
mailto:email="jstok@bluedog.apana.org.au>
> > Consider the following:
> >
> > >> testtext = ['Four', 'lines', 'of', 'text',]
> > >> def myprint(item):
> > ...    print item
> > ...
> > >>> result = map(print, testtext)
> >   File "<string>", line 1
> >      map(print, testtext)
> >              ^
> >  SyntaxError: invalid syntax
> > >>> result = map(myprint, testtext)
> > Four
> > lines
> > of
> > text
> > >>>
> >
> > Clearly I can't use "print" the same way I use "myprint".  Why?
>
> "print" is not a function, print is a statement.
> </quote>
>
> 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-----
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
>