Several approaches are available to accomplish this. Below are some of the features.
Using array
From the list
Replace the last line of code in the question with the following.
a.fromlist([int(val) for val in stdin.read().split()])
Now:
>>> a array('i', [1, 2, 3, 4, 5, 6])
Con: does not preserve the 2d structure (see comments).
From generator
Note: this option is included in the eryksun comment.
A more efficient way to do this is to use a generator instead of a list. Replace the last two lines of code in the question with:
a = array('i', (int(val) for row in stdin for val in row.split()))
This gives the same result as above, but avoids creating an interim list.
Using the NumPy Array
If you want to maintain a 2d structure, you can use a NumPy array. Here is the whole example:
from StringIO import StringIO import numpy as np
Now:
>>> a array([[1, 2], [3, 4], [5, 6]])
Using standard lists
It is unclear whether the Python list is suitable. If so, one way to achieve the goal is to replace the last two lines of code in the next question.
a = [map(int, row.split()) for row in stdin]
After doing this, we have:
>>> a [[1, 2], [3, 4], [5, 6]]