25 Feb
2014
25 Feb
'14
7:38 a.m.
Ram Rachum wrote:
This actually makes me think that `range(int('inf'))` is a more elegant construct than `itertools.count()`. Also `range(x, int('inf'))` for `itertools.count(x)`,
You could achieve that with range(None) or range(start, None) which would be similar to slices like items[start:None] aka items[start:].
and then you have `range(x, int('inf'), y)` or `range(0, int('-inf'), -1)` which `itertools.count` can't cover.
This *is* covered by count():
[x for x in itertools.islice(itertools.count(step=-2), 10)] [0, -2, -4, -6, -8, -10, -12, -14, -16, -18]
All you save is one import. In return you'll see your applications break in new and interesting ways ;)