title: transpose/rotate a block of a matrix in python
body: <p>i have a 6x6 matrix as a list of lists in python. The matrix is divided into 4 square blocks of size 3x3. I want a way to take a transpose of only 1 block. I can do it using the traditional method of going through each element and copying it into another array and back and so on but I want to see if there is a better way, (transposing a matrix in python can be done in one line using the zip method)</p>
  
  <p>for eg this is the representation of the matrix and its blocks</p>
  
  <pre><code> block 1  block 2
  +-------+-------+
  | . . . | . . . |
  | . . 2 | 1 . . |
  | . . . | . . . |
  +-------+-------+
  | . . . | . . . |
  | . . . | . . . |
  | . 1 . | . . . |
  +-------+-------+
   block 3  block 4
  </code></pre>
  
  <p>and rotate(3, right) should result in this </p>
  
  <pre><code> block 1  block 2
  +-------+-------+
  | . . . | . . . |
  | . . 2 | 1 . . |
  | . . . | . . . |
  +-------+-------+
  | . . . | . . . |
  | 1 . . | . . . |
  | . . . | . . . |
  +-------+-------+
   block 3  block 4
  </code></pre>
  
  <p>I want to find a method that takes in a block number and rotates only that block left or right. Is there any easy way to do it?</p>