Recursive list comprehension

Terry Reedy tjreedy at
Thu Dec 9 04:25:27 CET 2004

"Steven Bethard" <steven.bethard at> wrote in message 
news:LoNtd.465310$wV.295778 at attbi_s54...
> What is the getnext protocol?  Is that the same thing that the iter() 
> docs call the sequence protocol?

Yes. (I meant to write getitem rather than getnext.)

>  Because this definitely still works with itertools:

Yes, not because itertools are cognizant of sequence objects but because 
itertools apply iter() to inputs and because iter() currently accomodates 
sequence-protocol objects as well as iterable-protocol objects by wrapping 
the former with builtin <iterator> objects.  I expect that may change if 
and when the builtin C-coded types are updated to have __init__ methods. 
This is a ways off, if ever, but I think the general advice for user code 
is to use the newer protocol.  So, for the purpose of writing new code, I 
think it justified to forget about or at least ignore the older iteration 

Terry J. Reedy

More information about the Python-list mailing list