all pairs of items in a list without indexing?

Steven Bethard steven.bethard at gmail.com
Wed Sep 29 00:09:24 CEST 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