[Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-22 Thread Jim Jewett
Greg Ewing wrote: But if the docs don't mention anything about true or false values for some particular type, one tends to assume that all values are true, as is the default for user-defined classes. The tutorials and such stress that python doesn't typically care about a specific True or

Re: [Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-22 Thread Guido van Rossum
On 9/22/05, Jim Jewett [EMAIL PROTECTED] wrote: Is there anything left? is a pretty analogy for iterators, But unmaintainable for iterators in general. This was considered ad nauseam when iterators were initially introduced, and it was an explicit decision *not* to provide an API to look ahead.

Re: [Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-22 Thread Greg Ewing
Jim Jewett wrote: Is there anything left? is a pretty analogy for iterators, particularly since the examples tend to start with list or file iterators. But this can't be supported by all iterators, so it would be something special to these iterators. Keeping track of the peculiarities of

Re: [Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-21 Thread Raymond Hettinger
[Guido van Rossum] Could you at least admit that this was an oversight and not try to pretend it was intentional breakage? Absolutely. I completely missed this one. Raymond ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-21 Thread Greg Ewing
Raymond Hettinger wrote: The Boolean value of an iterator is certainly not promised by the iterator protocol as specified in the docs or the PEP. But if the docs don't mention anything about true or false values for some particular type, one tends to assume that all values are true, as is the

Re: [Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-21 Thread Guido van Rossum
On 9/21/05, Raymond Hettinger [EMAIL PROTECTED] wrote: [Guido van Rossum] Could you at least admit that this was an oversight and not try to pretend it was intentional breakage? Absolutely. I completely missed this one. Thanks; spoken like a man. I strongly feel that this needs to be

[Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-21 Thread Raymond Hettinger
[Guido] I strongly feel that this needs to be corrected in 2.5. Iterators should have neither __len__ nor __nonzero__. Right. I'll get it fixed-up. [Terry Reedy] I presume there were two reasons: internal efficiency of preallocations (list(some_it) for example) [Guido] This could

[Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-20 Thread Guido van Rossum
I just finished debugging some code that broke after upgrading to Python 2.4 (from 2.3). Turns out the code was testing list iterators for their boolean value (to distinguish them from None). In 2.3, a list iterator (like any iterator) is always true. In 2.4, an exhausted list iterator is false;

Re: [Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-20 Thread Fred L. Drake, Jr.
On Tuesday 20 September 2005 17:49, Guido van Rossum wrote: I realize that this was a deliberate feature, and that it exists in 2.4 as well as in 2.4.1 and will in 2.4.2; yet, I'm not sure I *like* I wasn't paying any attention at the time, so I don't know what was discussed. Some

Re: [Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-20 Thread Delaney, Timothy (Tim)
Fred L. Drake, Jr. wrote: On Tuesday 20 September 2005 17:49, Guido van Rossum wrote: I realize that this was a deliberate feature, and that it exists in 2.4 as well as in 2.4.1 and will in 2.4.2; yet, I'm not sure I *like* I wasn't paying any attention at the time, so I don't know

Re: [Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-20 Thread Guido van Rossum
On 9/20/05, Delaney, Timothy (Tim) [EMAIL PROTECTED] wrote: In any case, it's simple to get the 2.3 behaviour back - just add __nonzero__. I think that could validly be considered a bugfix. Alas not -- it would still be a functionality change relative to 2.4 and 2.4.1. Also, an object whose

Re: [Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-20 Thread Raymond Hettinger
[Guido] I just finished debugging some code that broke after upgrading to Python 2.4 (from 2.3). Turns out the code was testing list iterators for their boolean value (to distinguish them from None). In 2.3, a list iterator (like any iterator) is always true. In 2.4, an exhausted list

Re: [Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-20 Thread Terry Reedy
Guido van Rossum [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I just finished debugging some code that broke after upgrading to Python 2.4 (from 2.3). Turns out the code was testing list iterators for their boolean value (to distinguish them from None). This seem unnecessarily

Re: [Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-20 Thread Guido van Rossum
On 9/20/05, Raymond Hettinger [EMAIL PROTECTED] wrote: [Guido] I just finished debugging some code that broke after upgrading to Python 2.4 (from 2.3). Turns out the code was testing list iterators for their boolean value (to distinguish them from None). In 2.3, a list iterator (like any

Re: [Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-20 Thread Guido van Rossum
On 9/20/05, Terry Reedy [EMAIL PROTECTED] wrote: I presume there were two reasons: internal efficiency of preallocations (list(some_it) for example) This could have been implemented without making the implementation details public. and letting people differentiate iterator with something

Re: [Python-Dev] bool(iter([])) changed between 2.3 and 2.4

2005-09-20 Thread Greg Ewing
Guido van Rossum wrote: I just finished debugging some code that broke after upgrading to Python 2.4 (from 2.3). Turns out the code was testing list iterators for their boolean value (to distinguish them from None). In 2.3, a list iterator (like any iterator) is always true. In 2.4, an