<div dir="ltr">On Tuesday, June 5, 2018 at 12:19:53 AM UTC-7, Ben Rudiak-Gould wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">When the loop is simple enough I can write
<br>
<br>    items = [... for item in items]
<br>
<br>and when it's complicated enough it probably makes sense to split it
<br>into a separate function. But I've many times wished that I could
<br>write
<br>
<br>    for item in items.pop_all():
<br>        ...
<br>        items.append(...)
<br>        ...
<br></blockquote><div><br></div><div>Isn't it equally easy to write:</div><div><br></div><div>    def foo(x):</div><div>        ...</div><div><br></div><div>    items = [foo(x) for x in items]</div><div><br></div><div><br></div><div>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.</div></div>