On Tuesday, June 5, 2018 at 12:19:53 AM UTC-7, Ben Rudiak-Gould wrote: > > When the loop is simple enough I can write > > items = [... for item in items] > > and when it's complicated enough it probably makes sense to split it > into a separate function. But I've many times wished that I could > write > > for item in items.pop_all(): > ... > items.append(...) > ... >
Isn't it equally easy to write: def foo(x): ... items = [foo(x) for x in items] I don't understand the desire to write this as a loop over a ``items.pop(slice(None))``. You can simply use the same loop body, replacing the ``for x in items:`` with ``def blah(x):`` and ``items.append(y)`` with ``return y``. Low typing effort.
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/