-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTable.py
More file actions
23 lines (17 loc) · 730 Bytes
/
Table.py
File metadata and controls
23 lines (17 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Table:
def __init__(self, rows_count = 0, columns_count = 0):
self.rows = [Row(i, columns_count) for i in range(rows_count)]
def with_values(self, rows):
self.rows = [Row().from_values(i, row) for i, row in enumerate(rows)]
class Row:
def __init__(self, row_index=0, cells_count=0):
self.row_index = row_index
self.cells = [Cell(self, i) for i in range(cells_count)]
def from_values(self, row_index, values):
self.row_index = row_index
self.cells = [Cell(self, i, value) for i, value in enumerate(values)]
class Cell:
def __init__(self, row, cell_index, value=None):
self.row = row
self.index = cell_index
self.value = value