Having trouble rewriting code to list comprehension for image rotation in python
<p>So after not finding my problem here on stackoverflow, which is how to rewrite a for-loop to a list comprehension, where values are inserted I have to ask now if it possible to rewrite this code:</p>

<pre><code>rotate = np.zeros((w,h,c), np.uint8) # create an empty image filled with zeros turned 90Â°

for y in xrange(h):
    for x in xrange(w):
        rotate[x][y] = img[y][x]
</code></pre>

<p>into list comprehension? I thought something like this would work, but it didn't:</p>

<pre><code>rotate[x][y] = img[y][x] for y in range(h) for x in range(w) 
</code></pre>

<p>after that I just played around with various combinations of adding indexes and brackets and I always got some syntax errors. Just for the record, I know that there are functions for rotation of images in opencv and in numpy, I'm just interested in rewriting the  for-loop to list-comprehension.</p>

<pre><code>rotate = np.array([[img[y][x] for y in xrange(h)] for x in xrange(w)])
</code></pre>

python opencv numpy list-comprehension