[docs] [issue14836] Add next(iter(o)) to set.pop, dict.popitem entries.

Nadeem Vawda report at bugs.python.org
Thu May 17 10:43:55 CEST 2012

Nadeem Vawda <nadeem.vawda at gmail.com> added the comment:

> "popitem() 
> Remove and return an arbitrary (key, value) pair from the dictionary. Raises KeyError if the dict is empty. Use next(iter(d)) to return an arbitrary pair without removing it."

Actually, next(iter(d)) on a dict returns an arbitrary *key*; if you want
a pair, you need next(iter(d.items())).

nosy: +nadeem.vawda

Python tracker <report at bugs.python.org>

More information about the docs mailing list