Skip to content

Instantly share code, notes, and snippets.

@micaiahparker
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micaiahparker/a60423e9cf25c73088bc to your computer and use it in GitHub Desktop.
Save micaiahparker/a60423e9cf25c73088bc to your computer and use it in GitHub Desktop.
class Grid():
def __init__(self, rows, cols, fill = 0):
self.rows = rows
self.cols = cols
self.fill = fill
self.grid = self.make_grid(self.rows, self.cols, self.fill)
def make_grid(self, rows, cols, fill):
#return [[self.fill for col in range(self.cols)] for row in range(self.rows)]
local = []
for row in range(self.rows):
local.append([])
for row in range(self.rows):
for col in range(self.cols):
local[row].append(self.fill)
return local
def display(self):
for row in self.grid:
print(row)
def main():
main_grid = Grid.make_grid(3,3,Grid(10,10)) #makes a 3x3 grid filled with 10x10 Grid objects
print(main_grid[4][5].grid[2][4])
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment