extract multiple ranges from a list

pi.arctan at gmail.com pi.arctan at gmail.com
Sat Mar 8 16:28:35 CET 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):

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
y = [0:352 704:1056 ... ]


More information about the Python-list mailing list