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 _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/EW6UZ3YXXN7APDAZ6M5WQX7S7GP7JCHO/ Code of Conduct: http://python.org/psf/codeofconduct/