title: Why use List instead of Tuple to represent a game board?
body: <p>In the <a href="http://inventwithpython.com/pygame/chapter7.html" rel="nofollow">Tetris game in the PyGame book</a>, they create a board using:</p>
  
  <pre><code> board = []
   for i in range(BOARDWIDTH):
      board.append([BLANK] * BOARDHEIGHT)
   return board
  </code></pre>
  
  <p>While that's fine, a list of lists, I was thinking about how they usually represent that in Java and other languages, as an array with set index - for example, <code>int board[][] = new int[8][8]; // create 64 integers</code> (a <a href="http://www.willamette.edu/~gorr/classes/cs231/lectures/chapter9/arrays2d.htm" rel="nofollow">2d array example</a>).</p>
  
  <p>From what I understand, tuples are more similar to the array (vs List which is more like ArrayList or LinkedList of Java). They have set number of elements and can't be added to, and hold a set number of items.</p>
  
  <p>Why would we not create a tuple of tuples for a board, for example </p>
  
  <pre><code>board = ( (BLANK,)*10 ,)*10
  </code></pre>
  
  <p>Do they use lists of lists for some optimization in Python's internal representation of the board, or just because they assume users know List more commonly than Tuple?</p>
  
  <p>This has the added benefit of being functional and making immutable objects. If you want to make a board with a state in which you moved in tic tac toe for example, you could try something like:</p>
  
  <pre><code>tictac = ((0,0,0),)*3
  vals = (tuple((tictac[r][c]) if r!=1 or c!=1 else 'x' for (r,row) in enumerate(tictac)) for c in range(3))
  for i in vals: print i
  </code></pre>
  
  <p>to move a 1 to the center.</p>
  
  <p>List comprehensions are quite flexible in Python and this is more functionally-correct.</p>