Re: when an iterable object is exhausted or not

2012-08-04 Thread Ramchandra Apte
An important use of range repeating. one_to_10 = range(1,10) one_to_5 = range(1,5) for x in one_to_5: for x in one_to_10:pass if range wasn't repeatable, range would have to be called 5 times compared with 1! On 5 August 2012 07:43, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote

Re: when an iterable object is exhausted or not

2012-08-04 Thread Steven D'Aprano
On Sat, 04 Aug 2012 21:20:36 +0200, Franck Ditter wrote: > Two similar iterable objects but with a different behavior : [...] > IMHO, this should not happen in Py3k. What is the rationale of this (bad > ?) design, which forces the programmer to memorize which one is > exhaustable and which one is

Re: when an iterable object is exhausted or not

2012-08-04 Thread Steven D'Aprano
On Sat, 04 Aug 2012 12:44:07 -0700, Tim Roberts wrote: >>$$$ i = filter(lambda c : c.isdigit(), 'a1b2c3') >>$$$ for x in i : print(x,end=' ') >>1 2 3 >>$$$ for x in i : print(x,end=' ')# i is exhausted >>$$$ >> >>IMHO, this should not happen in Py3k. > > It's interesting that it DOESN'T

Re: when an iterable object is exhausted or not

2012-08-04 Thread Terry Reedy
On 8/4/2012 4:24 PM, Tim Chase wrote: On 08/04/12 14:20, Franck Ditter wrote: Two similar iterable objects but with a different behavior : $$$ i = range(2,5) $$$ for x in i : print(x,end=' ') 2 3 4 $$$ for x in i : print(x,end=' ')# i is not exhausted 2 3 4 - Compare with :

Re: when an iterable object is exhausted or not

2012-08-04 Thread Tim Chase
On 08/04/12 14:20, Franck Ditter wrote: > Two similar iterable objects but with a different behavior : > > $$$ i = range(2,5) > $$$ for x in i : print(x,end=' ') > > 2 3 4 > $$$ for x in i : print(x,end=' ')# i is not exhausted > > 2 3 4 > > - Compare with : > > $$$ i = fi

Re: when an iterable object is exhausted or not

2012-08-04 Thread MRAB
On 04/08/2012 20:20, Franck Ditter wrote: Two similar iterable objects but with a different behavior : $$$ i = range(2,5) $$$ for x in i : print(x,end=' ') 2 3 4 $$$ for x in i : print(x,end=' ')# i is not exhausted 2 3 4 - Compare with : $$$ i = filter(lambda c : c.isdigit()

Re: when an iterable object is exhausted or not

2012-08-04 Thread Tim Roberts
Franck Ditter wrote: > >Two similar iterable objects but with a different behavior : > >$$$ i = range(2,5) >$$$ for x in i : print(x,end=' ') > >2 3 4 >$$$ for x in i : print(x,end=' ')# i is not exhausted > >2 3 4 > >- Compare with : > >$$$ i = filter(lambda c : c.isdigit(),

when an iterable object is exhausted or not

2012-08-04 Thread Franck Ditter
Two similar iterable objects but with a different behavior : $$$ i = range(2,5) $$$ for x in i : print(x,end=' ') 2 3 4 $$$ for x in i : print(x,end=' ')# i is not exhausted 2 3 4 - Compare with : $$$ i = filter(lambda c : c.isdigit(), 'a1b2c3') $$$ for x in i : print(x,en