This is not really the best syntax, but I thought this generator expression
might be of interest:

counter = (d.update(n=d['n']+1) or d['n'] for d in [dict(n=-1)] for _ in
iter(int,1))


It counts forever starting at 0. I was playing with only using generator
syntax...

On Fri, Jun 19, 2020 at 1:32 PM Steele Farnsworth <swfarnswo...@gmail.com>
wrote:

> > I don't see the value myself, but in theory it would make sense to
> have both bounded and infinite ranges be able to be processed the same
> way.
>
> My thinking is that if we wanted to represent an unbounded range as a
> mathematical entity (rather than a tool for iteration), we should let that
> exist in numpy or another mathematical package so that it can have whatever
> functionality a mathematician would want it to have without being tied up
> to the cpython release cycle or backwards compatibility constraints.
>
> Steele
>
> On Fri, Jun 19, 2020 at 12:47 PM Chris Angelico <ros...@gmail.com> wrote:
>
>> On Sat, Jun 20, 2020 at 2:39 AM Steele Farnsworth
>> <swfarnswo...@gmail.com> wrote:
>> > If range were to support infinite ranges, range.__len__ would have to
>> be changed to either raise an error or return float('inf') in these cases.
>>
>> That would be a problem that would have to be solved, as would related
>> concepts like what slicing with negative indices would do - what's
>> range(0, ...)[:-10] give? This doesn't mean the idea is dead in the
>> water, but anyone who's proposing it will need to come up with answers
>> to these questions.
>>
>> > I believe __contains__ would also need to have extra checks.
>> >
>>
>> That'd be easy enough. The check "x in r" has to check three things:
>> is x >= r.start, is r < x.stop, and is (x - r.start) % r.step == 0.
>> Having an infinite end point would simply remove the need for the
>> middle check (or have it always be true).
>>
>> Be aware that this idea is meaningful ONLY for the 'stop' parameter.
>> An infinite start or step makes no sense.
>>
>> I don't see the value myself, but in theory it would make sense to
>> have both bounded and infinite ranges be able to be processed the same
>> way.
>>
>> ChrisA
>> _______________________________________________
>> Python-ideas mailing list -- python-ideas@python.org
>> To unsubscribe send an email to python-ideas-le...@python.org
>> https://mail.python.org/mailman3/lists/python-ideas.python.org/
>> Message archived at
>> https://mail.python.org/archives/list/python-ideas@python.org/message/KYDECOSQCTAE5QJN5HJICZBJVUNQ45CB/
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/VD2BHQIGME3ABUSBEQXHYPIWOTBTNMZR/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/YFBTF5X5AL6QAOILQ74UMBDAIKI2NMD3/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to