10 Oct
2021
10 Oct
'21
1:15 p.m.
Steven D'Aprano writes:
On Sun, Oct 10, 2021 at 01:51:52AM +0900, Stephen J. Turnbull wrote:
Christopher Barker writes:
But last time, one of the use cases was "get [an arbitrary] item from a dict", and there really is not a terribly easy (and efficient) way to do that now.
What's wrong with thedict.popitem()? Works in Python 2.7, BTW.
It removes the key and value, not just retrieve them.
So does next() on an iterator. If you're sampling with replacement, replace them. At least you can do that with dicts! The incoherence of polymorphic 'first' is my main point. I don't see why this is any worse than modifying an iterator in 'first'. Steve