map() question...

Andrew Bennetts andrew-pythonlist at
Mon Jan 13 03:42:53 CET 2003

On Sun, Jan 12, 2003 at 11:50:50PM +0000, Kevin Ethridge wrote:
> Why doesn't map() work with the print function?
> ie map(print, ['Have', 'a', 'great', 'day.'])

Simple -- print isn't a function :)

It's a statement, which is why you can do
    print 'Hi!'
without parens.

This works:

    def prnt(val):
        print val
    map(prnt, ['Have', 'a', 'great', 'day.'])

Alternatively, you could use sys.stdout.write as the function.


More information about the Python-list mailing list