[Python-ideas] `OrderedDict.items().__getitem__`

Chris Angelico rosuav at gmail.com
Sat Jan 11 22:41:03 CET 2014


On Sun, Jan 12, 2014 at 7:51 AM, Ryan Gonzalez <rymg19 at gmail.com> wrote:
> Based on your popitem idea:
>
> get_first = lambda d: d.copy().popitem()
> get_last = lambda d: d.copy().popitem(last=True)

That's a destructive operation, though. Great if you want it, terrible
if you don't.

ChrisA


More information about the Python-ideas mailing list