Hacker News new | ask | show | jobs
by darkseas 4400 days ago
I use

    map(print, list_of_tuples)
quite a bit, but that possibly an artifact of my print-based debugging. I can only do this with print as a function rather than a statement, and the single line makes it easy to drop in or comment out as needed.
3 comments

map(print, list_of_tuples) does not work on Python 3 unless you wrap it in list(). In any case it's a anti-idiom because it creates a useless list. Please don't do that.
Ah, I can see now that `map` will return a list of Nones, and also that Py3 `map` returns a lazy iterator. Thanks.

Seeing how my transition to Py3 got hung up on sending bytes in and out of ZeroMQ sockets, I might stop that now.

Back to the for loop or join the strings as suggested below.

    >>> from pprint import pprint; pprint(list_of_tuples)
Print '\n'.join(str(x) for x in list_of_tuples)

Not as nice, but doable.