4 ms·
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 rathe
by darkseas 12y 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.
- njharman 12y agoPrint '\n'.join(str(x) for x in list_of_tuples) Not as nice, but doable.
- the_mitsuhiko 12y agomap(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.
- darkseas 12y agoAh, 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.
- mborch 12y ago>>> from pprint import pprint; pprint(list_of_tuples)