[Python-ideas] Re: Extend the range functionality to allow infinite ranges

2020-06-19 Thread Robert DeLanghe
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

[Python-ideas] Re: Extend the range functionality to allow infinite ranges

2020-06-19 Thread Steele Farnsworth
> 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

[Python-ideas] Re: Extend the range functionality to allow infinite ranges

2020-06-19 Thread Ricky Teachey
On Fri, Jun 19, 2020 at 12:29 PM Ricky Teachey wrote: > On Fri, Jun 19, 2020 at 12:25 PM wrote: > >> Proposal: >> range(start, ..., step) >> should function like >> itertools.count(start, step) >> >> Reason: >> It's pretty common to see people do things where they increment a count >> within a w

[Python-ideas] Re: Extend the range functionality to allow infinite ranges

2020-06-19 Thread Chris Angelico
On Sat, Jun 20, 2020 at 2:39 AM Steele Farnsworth 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

[Python-ideas] Re: Extend the range functionality to allow infinite ranges

2020-06-19 Thread Rhodri James
On 19/06/2020 17:11, ke...@edinburghacademy.org.uk wrote: Reason: It's pretty common to see people do things where they increment a count within a while True loop, and it would be nice to have something easily available for people to use to replace this. Sorry, but I'm failing to see the use ca

[Python-ideas] Re: Extend the range functionality to allow infinite ranges

2020-06-19 Thread Steele Farnsworth
I suppose my previous message totally ignored that you acknowledged that itertools.count exists. 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. I believe __contains__ would also need to have extra che

[Python-ideas] Re: Extend the range functionality to allow infinite ranges

2020-06-19 Thread Ricky Teachey
On Fri, Jun 19, 2020 at 12:25 PM wrote: > Proposal: > range(start, ..., step) > should function like > itertools.count(start, step) > > Reason: > It's pretty common to see people do things where they increment a count > within a while True loop, and it would be nice to have something easily > ava

[Python-ideas] Re: Extend the range functionality to allow infinite ranges

2020-06-19 Thread Steele Farnsworth
You can get this behavior with itertools.count On Fri, Jun 19, 2020, 12:23 PM wrote: > Proposal: > range(start, ..., step) > should function like > itertools.count(start, step) > > Reason: > It's pretty common to see people do things where they increment a count > within a while True loop, and i

[Python-ideas] Re: Extend the range functionality to allow infinite ranges

2020-06-19 Thread David Mertz
How on earth is "count()" not easily available? On Fri, Jun 19, 2020 at 12:23 PM wrote: > Proposal: > range(start, ..., step) > should function like > itertools.count(start, step) > > Reason: > It's pretty common to see people do things where they increment a count > within a while True loop, an