title: python: create lists dynamically
body: <p>I am trying to create a list of 3D indexes in python. One way I can do is iterate over all the ids in nested loops and do as follows:</p>
  
  <pre><code>l = list()
  
  for z in range(0, 2):
      for y in range(1, 5);
          for x in range(1, 10):
              l.append((x, y, z))
  </code></pre>
  
  <p>However, I remember there was a one liner way to do this but for the life of me I cannot figure it out. I tried something like:</p>
  
  <pre><code>l.append((x, y, z) for x in range(0, 10), for y in range(0, 10), for z in range(0, 2))
  </code></pre>
  
  <p>However, this resulted in a syntax error.</p>