On 6 Aug 2007, at 16:22, Steven Bethard wrote:

> On 8/6/07, Nicko van Someren <[EMAIL PROTECTED]> wrote:
...
>> Filter returning an iterator is going to break lots of code which
>> says things like:
>>         interesting_things = filter(predicate, things)
>>         ...
>>         if foo in interesting_things: ...
>
> Actually, as written, that code will work just fine::
> ...
> Perhaps you meant to have multiple if clauses?

You're right, I did!  I wrote an much longer example with multiple  
ifs and it looked too verbose, so I edited it down, and lost the  
meaning.

In fact, from a bug tracing point of view it's even worse, since,  
reusing your example, code with currently reads:
        interesting_things = filter(str.isalnum, 'a 1 . a1 a1.'.split())
        if '1' in interesting_things:
                print "Failure"
        if 'a1' in interesting_things:
                print "... is not an option"
will currently do the same as, but in v3 will be different from:
        interesting_things = filter(str.isalnum, 'a 1 . a1 a1.'.split())
        if 'a1' in interesting_things:
                print "Failure"
        if '1' in interesting_things:
                print "... is not an option"

If filter() really has to be made to return an iterator then (a) 2to3  
is going to have to make lists of its output and (b) the behaviour is  
going to need to be very clearly documented.  I do think that many  
people are going to be confused by this change.

        Nicko

_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to