Can a List Comprehension do ____ ?

Eric @ Zomething eric at zomething.com
Thu Jul 15 01:42:22 EDT 2004


Steve <lonetwin at gmail.com>  and other esteemed Pythonistas wrote:

[snip]

> [(breaks[i][1], breaks[i+1][0]) for i in range(len(breaks) - 1)]

[snip]

>>> it = iter(breaks)
>>> [(start, end) for ((_, start), (end, _)) in zip(it, it)]

[snip]

> [ (max(b[i]), min(b[i+1])) for i in range(len(breaks)) if i+1 < len(breaks) ]

[snip]

>>> spans = [(x[1],y[0]) for x,y in zip(breaks, breaks[1:])]

[snip]

And a bunch of guidance that was better than a fresh cup of coffee.


Thanks!



Eric Pederson
http://www.songzilla.blogspot.com
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
e-mail me at:
do at something.com
except, increment the "d" and "o" by one letter
and spell something with a "z"
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



More information about the Python-list mailing list