> But it's actually shorter
It's not: with def() you have to explicitly write return, while with lambda it is implicit.
It's not: with def() you have to explicitly write return, while with lambda it is implicit.
For tghw's solution to work you'd have to have a print outside of the function call (since you can't print from a lambda). With the def, you can print inside of the function (and don't need a return, since you're just printing).
map(print, some_list)
Unfortunately, it returned a map object, which I guess is also new in Python 3 (I assume it's a lazy application device). print(*[1,2,3], sep='\n') def do(gen):
for x in gen:
pass
It evaluates all elements of a generator with storing them in memory. If you don't mind generating some garbage, you can just use the list function instead.