How to identify which numbers in a list are within each others' range

Boris Borcic bborcic at gmail.com
Fri Feb 8 08:48:37 EST 2008


Arnaud Delobelle wrote:
(...)
> 
> from itertools import chain
> 
> def overlaps(lst):
>     bounds = chain(*(((x[1],i), (x[2], i)) for i,x in enumerate(lst)))

imho, this is a uselessly painful equivalent of

       bounds = ((x[k],i) for i,x in enumerate(lst) for k in (1,2))

Cheers, BB



More information about the Python-list mailing list