From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 29 Feb 2024 17:37:00 +0000 (+0100) Subject: [3.12] Make the iter_except() recipe more compact. (gh-116132) (gh0116133) X-Git-Tag: v3.12.3~180 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=010aac7c1a43afd63b4c4019c4f217f1e3a72689;p=thirdparty%2FPython%2Fcpython.git [3.12] Make the iter_except() recipe more compact. (gh-116132) (gh0116133) --- diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index f265e046afc8..2e6d5eeb12d2 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -975,28 +975,10 @@ which incur interpreter overhead. """ Call a function repeatedly until an exception is raised. Converts a call-until-exception interface to an iterator interface. - Like builtins.iter(func, sentinel) but uses an exception instead - of a sentinel to end the loop. - - Priority queue iterator: - iter_except(functools.partial(heappop, h), IndexError) - - Non-blocking dictionary iterator: - iter_except(d.popitem, KeyError) - - Non-blocking deque iterator: - iter_except(d.popleft, IndexError) - - Non-blocking iterator over a producer Queue: - iter_except(q.get_nowait, Queue.Empty) - - Non-blocking set iterator: - iter_except(s.pop, KeyError) - """ + # iter_except(d.popitem, KeyError) --> non-blocking dictionary iterator try: if first is not None: - # For database APIs needing an initial call to db.first() yield first() while True: yield func() @@ -1004,7 +986,6 @@ which incur interpreter overhead. pass - The following recipes have a more mathematical flavor: .. testcode::