all pairs of items in a list without indexing?

Steven Bethard steven.bethard at gmail.com
Tue Sep 28 18:09:24 EDT 2004


<jepler <at> unpythonic.net> writes:
>     def all_pairs(L):
>         while L:
>             i = L.pop()
>             for j in L: yield i, j

Interesting.  I hadn't thought of this one -- it's not bad other than 
requiring the list copy (since I need to maintain the original list).

Thanks,

Steve




More information about the Python-list mailing list