Creating a matrix?

Ivan Voras iv at an.voras.fer
Fri Apr 2 10:01:11 EST 2004


Is there a nice(r) way of creating a list of uniform values? I'm currently 
using: list('0'*N), which makes a string and then chops it up into a list. I 
need it to create a NxN matrix:

matrix = [list('0'*N) for i in range(N)]

(elements need to be mutable afterwards, a shallow copy is bad)

While this is short and concise, it also feels odd :)



More information about the Python-list mailing list