[Python-ideas] Unbounded range(), was Re: Allow __len__ to return infinity
Ram Rachum
ram at rachum.com
Tue Feb 25 13:46:04 CET 2014
I stand corrected.
On Tue, Feb 25, 2014 at 2:38 PM, Peter Otten <__peter__ at web.de> wrote:
> 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 ;)
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "python-ideas" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python-ideas/nFYbEpHrjlk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python-ideas+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140225/c7fe157e/attachment-0001.html>
More information about the Python-ideas
mailing list