E
Eric @ Zomething
Pythonistas,
I seem at a loss for a List Comprehension syntax that will do what I want.
I have a list of string position spans:
[(133, 137), (181, 185), (227, 231), (232, 236), (278, 282), (283, 287), (352, 356), (412, 416), (485, 489), (490, 494)]
the first pair representing: someString[133:137]
What I want is a list of the positions between these spans, which would look like this:
[[(137, 181)], [(185, 227)], [(231, 232)], [(236, 278)], [(282, 283)], [(287, 352)], [(356, 412)], [(416, 485)], [(489, 490)]]
Of course I can get such a list, but I haven't been able to figure out how to do this with a List Comprehension. I am wondering if there is a syntax which makes pairs of the maximum of one list element and the minimum of the next list element.
Can anyone show me the List Comprehensions light?
Was trying things like this:
With regards
Eric Pederson
http://www.songzilla.blogspot.com
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
e-mail me at:
(e-mail address removed)
except, increment the "d" and "o" by one letter
and spell something with a "z"
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
I seem at a loss for a List Comprehension syntax that will do what I want.
I have a list of string position spans:
[(133, 137), (181, 185), (227, 231), (232, 236), (278, 282), (283, 287), (352, 356), (412, 416), (485, 489), (490, 494)]
the first pair representing: someString[133:137]
What I want is a list of the positions between these spans, which would look like this:
[[(137, 181)], [(185, 227)], [(231, 232)], [(236, 278)], [(282, 283)], [(287, 352)], [(356, 412)], [(416, 485)], [(489, 490)]]
Of course I can get such a list, but I haven't been able to figure out how to do this with a List Comprehension. I am wondering if there is a syntax which makes pairs of the maximum of one list element and the minimum of the next list element.
Can anyone show me the List Comprehensions light?
Was trying things like this:
listSpans=[(max(x,y),min(a,b)) for (x,y) in breaks for (a,b) in breaks.pop()]
With regards
Eric Pederson
http://www.songzilla.blogspot.com
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
e-mail me at:
(e-mail address removed)
except, increment the "d" and "o" by one letter
and spell something with a "z"
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::