map() question...

Erik Max Francis max at alcyone.com
Sun Jan 12 21:50:29 EST 2003


Mike Meyer wrote:

> "Kevin Ethridge" <kevinethridge at yahoo.com> writes:
>
> > Why doesn't map() work with the print function?
> > ie map(print, ['Have', 'a', 'great', 'day.'])
> 
> Because print isn't a function, it's a statement. It will work with
> sys.stdout.write.

Only if wrapped in a lambda.  Don't forget that trailing newline that's
implicit in a print statement (one with no trailing comma, anyway):

	lambda x: sys.stdout.write(x + '\n')

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ If the sky should fall, hold up your hands.
\__/ (a Spanish proverb)
    Maths reference / http://www.alcyone.com/max/reference/maths/
 A mathematics reference.




More information about the Python-list mailing list