File tree Expand file tree Collapse file tree 1 file changed +1
-20
lines changed Expand file tree Collapse file tree 1 file changed +1
-20
lines changed Original file line number Diff line number Diff line change @@ -983,36 +983,17 @@ which incur interpreter overhead.
983983 """ Call a function repeatedly until an exception is raised.
984984
985985 Converts a call-until-exception interface to an iterator interface.
986- Like builtins.iter(func, sentinel) but uses an exception instead
987- of a sentinel to end the loop.
988-
989- Priority queue iterator:
990- iter_except(functools.partial(heappop, h), IndexError)
991-
992- Non-blocking dictionary iterator:
993- iter_except(d.popitem, KeyError)
994-
995- Non-blocking deque iterator:
996- iter_except(d.popleft, IndexError)
997-
998- Non-blocking iterator over a producer Queue:
999- iter_except(q.get_nowait, Queue.Empty)
1000-
1001- Non-blocking set iterator:
1002- iter_except(s.pop, KeyError)
1003-
1004986 """
987+ # iter_except(d.popitem, KeyError) --> non-blocking dictionary iterator
1005988 try:
1006989 if first is not None:
1007- # For database APIs needing an initial call to db.first()
1008990 yield first()
1009991 while True:
1010992 yield func()
1011993 except exception:
1012994 pass
1013995
1014996
1015-
1016997The following recipes have a more mathematical flavor:
1017998
1018999.. testcode ::
You can’t perform that action at this time.
0 commit comments