You might want to use numpy to reshape the array, too. Or if it's too much to import, you could make your own reshape function Try this:
import sys, numpy
if __name__ == '__main__':
x = sys.argv[1::3]
y = numpy.reshape(x, (5,5))
print y
I also notice that the call is adding the string once for each element of A, so you might consider using mat2str(A), like:
[str, err] = sprintf('/usr/local/python program.py "%s" ', mat2str(A));
I've also changed the %d to %s, because you're passing it as a string on the python anyway. The output of this is:
python program.py "[17 24 1 8 15;23 5 7 14 16;4 6 13 20 22;10 12 19 21 3;11 18 25 2 9]"
You can make a matrix from that string with numpy as well
>>> import sys
>>> import numpy
>>> print(numpy.matrix(sys.argv[1]))
matrix([[17, 24, 1, 8, 15],
[23, 5, 7, 14, 16],
[ 4, 6, 13, 20, 22],
[10, 12, 19, 21, 3],
[11, 18, 25, 2, 9]])