On 6/6/2014 9:59 PM, Neil Girdhar wrote:
That would be great.
What does 'that' refer too? Ram's original proposal, which you quoted, or Antony's counter-proposal, which you also quoted? Ambiguity is the cost of top-posting combined with over-quoting.
Since I already explained what is wrong with Ram's proposal, I will delete it and assume you mean Antony's, which seems to not have arrived on my machine.Having a parameter like 'start' mean two different things when passed by position and name is the sort of oddity we try to avoid.
On Friday, May 16, 2014 12:16:52 AM UTC-4, Antony Lee wrote:
Actually, a more reasonable solution would be to have range handle
keyword arguments and map "range(start=x)" to "count(x)".
Since "a range object is an immutable, constant attribute, reiterable sequence object" (my earlier post), while count is an iterator, that does not literally work. So I will assume that you mean (looking ahead) 'an iterable sis_range such that iter(sis_range(n, None, step)) is the same as count(n, step)'.As an expression, stop=None is literally what you mean.
Or, perhaps more simply, "range(x, None)"
The problem is that range is a finite sequence with a finite length and an indexable end. For instance, range(10)[-1] == 9. What is needed is a new semi_infinite_sequence base class 'SemiInfSeq' that allows (but not requires) infinite length: float('inf') or a new int('inf'). It would also have to disallow negative ints for indexing and slicing. Or perhaps a class factory is needed.
Many infinite iterators whose items can be calculated from index n could be the iterator for a SIS subclass. A geometric series and the sequence of squares are other examples. This could be a PyPI package.
--
Terry Jan Reedy