News for hackers. Stuff that matters.
Re:The fate of reduce() in Python 3000 (2005) by duckerude on Tuesday January 01, 2019 @10:19AM (#18800477)
I'm sometimes tempted to use it in loops, when

  for x in map(func, iterable):
      ...
is cleaner than

  for x in (func(y) for y in iterable):
      ...
and shorter than

  for y in iterable:
      x = func(y)
      ...
But that mostly only makes sense if you already have a suitable named function (e.g. str), and I usually end up going with the third variant anyway.

There's an analogous case with filter and `if not cond: continue`.

map and filter calls are trivially rewritten to generator expressions, but it's not necessarily an improvement.

There are no comments on this comment yet.