More elegant way to initialize list of duplicated items in Python
<p>If I want a list initialized to 5 zeroes, that's very nice and easy:</p>

<pre><code>[0] * 5
</code></pre>

<p>However if I change my code to put a more complicated data structure, like a list of zeroes:</p>

<pre><code>[[0]] * 5
</code></pre>

<p>will not work as intended, since it'll be 10 copies of the same list. I have to do:</p>

<pre><code>[[0] for i in xrange(5)]
</code></pre>

<p>that feels bulky and uses a variable so sometimes I even do:</p>

<pre><code>[[0] for _ in "     "]
</code></pre>

<p>But then if i want a list of lists of zeros it gets uglier:</p>

<pre><code>[[[0] for _ in "     "] for _ in "     "]
</code></pre>

<p>all this instead of what I want to do:</p>

<pre><code>[[[0]]*5]*5
</code></pre>

<p>Has anyone found an elegant way to deal with this "problem"?</p>
