Use the nested list. Easy to set up:
field = [([None] * height) for x in range(width)]
field[x][y] = "*"
The brightest will probably be the new class:
class MineField(object):
class _SingleField(object):
mine = False
flagged = False
covered = True
width = None
height = None
def __init__(self, width, height):
super(MineField, self).__init__()
self.width = width
self.height = height
self._field = [[self._SingleField() for y in range(height)]
for x in range(width)]
self.init_field(10)
def init_field(self, minecount):
pass
def __getitem__(self, index):
x, y = index
return self._field[x][y]
Used as follows:
> m = MineField(10,10)
> m[4,9].mine
False