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
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
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
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 :
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
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()
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(),