Re: Question about exausted iterators

2006-05-20 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Christophe wrote: > Well, the main reason for such change is and will always be to catch > bugs. The fact is, using duct typing is something very common with the > Python language. Duct typing? I guess you mean duct taping, or duck taping [1] or maybe duck typing. :-)

Re: Question about exausted iterators

2006-05-19 Thread Mel Wilson
[EMAIL PROTECTED] wrote: > Consider this example: > X = range(5) Y = iter(X) Z = iter(Y) > > As you can see, X is a container, and Y is an iterator. > They are simliar in that "iter" works on them both. > > Cristoph claims that this causes confusion. > Why? Because "iter" doesn't

Re: Question about exausted iterators

2006-05-19 Thread [EMAIL PROTECTED]
Consider this example: >>> X = range(5) >>> Y = iter(X) >>> Z = iter(Y) As you can see, X is a container, and Y is an iterator. They are simliar in that "iter" works on them both. Cristoph claims that this causes confusion. Why? Because "iter" doesn't have the same meaning for both of them. For

Re: Question about exausted iterators

2006-05-19 Thread Christophe
Terry Reedy a écrit : > "Christophe" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Instead of saying that all works as intended could you be a little >>helpful and tell me why it was intended in such an obviously broken way >>instead ? > > > I answered both your explicit and

Re: Question about exausted iterators

2006-05-18 Thread Terry Reedy
"Christophe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >Instead of saying that all works as intended could you be a little >helpful and tell me why it was intended in such an obviously broken way >instead ? I answered both your explicit and implied questions in good faith. But

Re: Question about exausted iterators

2006-05-18 Thread Erik Max Francis
Christophe wrote: > Yes, I know perfectly well that the bugs were my fault. But this doesn't > prevent me from asking for a feature that will have ( in my opinion ) a > negligible effect of current valid code and will help all of us catch > errors earlier. ... and apparently choosing to ask in

Re: Question about exausted iterators

2006-05-18 Thread Christophe
Fredrik Lundh a écrit : > Christophe wrote: > >> Maybe I've used more iterables than most of you. Maybe I've been doing >> that wrong. > > > your problem is that you're confusing iterables with sequences. they're > two different things. Yes, I know perfectly well that the bugs were my fault.

Re: Question about exausted iterators

2006-05-18 Thread Fredrik Lundh
Christophe wrote: > Maybe I've used more iterables than most of you. Maybe I've been doing > that wrong. your problem is that you're confusing iterables with sequences. they're two different things. -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about exausted iterators

2006-05-18 Thread Christophe
Roel Schroeven a écrit : > Fredrik Lundh schreef: >> so what is a valid answer? > > > I think he wants to know why the spec has been written that way. > > The rationale mentions exhausted iterators: > > "Once a particular iterator object has raised StopIteration, will > it also raise StopIterat

Re: Question about exausted iterators

2006-05-18 Thread Christophe
Diez B. Roggisch a écrit : > Christophe wrote: > > >>Fredrik Lundh a écrit : >> >>>Christophe wrote: >>> >>> Because I'm still waiting for a valid answer to my question. The answer "Because it has been coded like that" or is not a valid one. >>> >>> >>>it's been coded like that because th

Re: Question about exausted iterators

2006-05-18 Thread Roel Schroeven
Fredrik Lundh schreef: > Christophe wrote: > Because I'm still waiting for a valid answer to my question. The answer "Because it has been coded like that" or is not a valid one. >>> it's been coded like that because that's what the specification >>> says: >>> >>> http://www.python.

Re: Question about exausted iterators

2006-05-18 Thread Christophe
Fredrik Lundh a écrit : > Christophe wrote: > Because I'm still waiting for a valid answer to my question. The answer "Because it has been coded like that" or is not a valid one. >>> >>> >>> it's been coded like that because that's what the specification says: >>> >>> http://www.pyt

Re: Question about exausted iterators

2006-05-18 Thread Diez B. Roggisch
Christophe wrote: > Fredrik Lundh a écrit : >> Christophe wrote: >> >>> Because I'm still waiting for a valid answer to my question. The >>> answer "Because it has been coded like that" or is not a valid one. >> >> >> it's been coded like that because that's what the specification says: >> >>

Re: Question about exausted iterators

2006-05-18 Thread Fredrik Lundh
Christophe wrote: >>> Because I'm still waiting for a valid answer to my question. The >>> answer "Because it has been coded like that" or is not a valid one. >> >> it's been coded like that because that's what the specification says: >> >> http://www.python.org/dev/peps/pep-0234/ > > I didn

Re: Question about exausted iterators

2006-05-18 Thread Christophe
Fredrik Lundh a écrit : > Christophe wrote: > >> Because I'm still waiting for a valid answer to my question. The >> answer "Because it has been coded like that" or is not a valid one. > > > it's been coded like that because that's what the specification says: > > http://www.python.org/dev

Re: Question about exausted iterators

2006-05-18 Thread Fredrik Lundh
Christophe wrote: > Because I'm still waiting for a valid answer to my question. The answer > "Because it has been coded like that" or is not a valid one. it's been coded like that because that's what the specification says: http://www.python.org/dev/peps/pep-0234/ -- http://mail.pytho

Re: Question about exausted iterators

2006-05-18 Thread Christophe
looping a écrit : > Christophe wrote: > >>Ok, call me stupid if you want but I know perfectly well the "solution" >>to that problem ! Come on, I was showing example code of an horrible >>gotcha on using iterators. >> > > > OK, your are stupid ;-) > Why asking questions when you don't want to lis

Re: Question about exausted iterators

2006-05-18 Thread looping
Christophe wrote: > Ok, call me stupid if you want but I know perfectly well the "solution" > to that problem ! Come on, I was showing example code of an horrible > gotcha on using iterators. > OK, your are stupid ;-) Why asking questions when you don't want to listen answers ? > > > Instead of

Re: Question about exausted iterators

2006-05-18 Thread Christophe
Terry Reedy a écrit : > "Christophe" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Is there a good reason why when you try to take an element from an >>already exausted iterator, it throws StopIteration instead of some other >>exception ? > > > Yes. > . > . > To distinguish

Re: Question about exausted iterators

2006-05-17 Thread George Sakkis
Christophe wrote: > Is there a good reason why when you try to take an element from an > already exausted iterator, it throws StopIteration instead of some other > exception ? I've lost quite some times already because I was using a lot > of iterators and I forgot that that specific function param

Re: Question about exausted iterators

2006-05-17 Thread Terry Reedy
"Christophe" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is there a good reason why when you try to take an element from an > already exausted iterator, it throws StopIteration instead of some other > exception ? Yes. . . To distinguish the control message "I am done yielding v

Question about exausted iterators

2006-05-17 Thread Christophe
Is there a good reason why when you try to take an element from an already exausted iterator, it throws StopIteration instead of some other exception ? I've lost quite some times already because I was using a lot of iterators and I forgot that that specific function parameter was one. Exemple :