all pairs of items in a list without indexing?

Steven Bethard steven.bethard at
Wed Sep 29 00:09:24 CEST 2004

<jepler <at>> 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).



More information about the Python-list mailing list