python-utils 4.0.1__py3-none-any.whl → 4.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
python_utils/aio.py CHANGED
@@ -35,7 +35,9 @@ async def acount(
35
35
  start: First value to yield.
36
36
  step: Amount added between successive values.
37
37
  delay: Seconds to ``asyncio.sleep`` between yields.
38
- stop: Exclusive upper bound; ``None`` counts forever.
38
+ stop: Exclusive bound, ``None`` counts forever. It is an upper bound
39
+ for a positive ``step`` and a lower bound for a negative one, the
40
+ way ``range`` reads it.
39
41
 
40
42
  Yields:
41
43
  The successive counter values.
@@ -46,7 +48,8 @@ async def acount(
46
48
  [0, 1, 2]
47
49
  """
48
50
  for item in itertools.count(start, step): # pragma: no branch
49
- if stop is not None and item >= stop:
51
+ # A negative step counts down, so `stop` is the lower bound there.
52
+ if stop is not None and (item <= stop if step < 0 else item >= stop):
50
53
  break
51
54
 
52
55
  yield item