extract multiple ranges from a list

pi.arctan at gmail.com pi.arctan at gmail.com
Sat Mar 8 10:28:35 EST 2008


Hi guys,

One of my many project involves working with YUV-files, where I need
to reduce
the vertical resolution with a factor of two, i.e. remove every other
scan line.
Today I'm using two for-loops in the fashion shown below

y = []
for i in range(0, width*height, width*2):
    for j in range(0,width):
        y.append(Y[i+j])

This approach doesn't feel very pythonic but I can't come up with a
better idea to do it.
I've tried list comprehension and map together with lambda but I can't
get a flattened list
of every other scan-line...

CIF = 352x288 items for luminance and the aim is to have the list
below:
y = [0:352 704:1056 ... ]

//Fredrik



More information about the Python-list mailing list