Lawrence D’Oliveiro writes: > On Tuesday, August 16, 2016 at 6:26:01 PM UTC+12, Paul Rudin wrote: >> sohcahtoa82 writes: >>> squared_plus_one_list = map(lambda x: x**2 + 1, some_list) >> >> I realise that this is about understanding lambda, but it's worth noting >> in passing that we tend to write this sort of thing as: >> >> squared_plus_one_list = [x**2 + 1 for x in some_list] > > The difference being that the “map” function takes an iterable and > returns an iterator.
They tend to write that sort of thing as: squared_plus_one_thing = (x**2 + 1 for x in some_thing) > Why could this difference be important? Different comprehensions (pun!) and performance characteristics. -- https://mail.python.org/mailman/listinfo/python-list