I am trying to design a spreadsheet app. I have been able to come up with a class for my Index which is typically the point consisting of row, col. I want to be able to assign a value to the point. The challenge is I am unable to update the value for that cell.
This is what I tried so far models.py
class Index(NamedTuple):
row: int
"""The row (y-coordinate)"""
col: int
"""The column (x-coordinate)"""
val: str = None
@property
def column_label(self):
nreps = (self.col // 26) + 1
char = chr(ord("A") + self.col % 26)
return nreps * char
@property
def row_label(self):
return str(self.row + 1)
def __str__(self):
if self.val:
return f"{self.val}"
return f"{self.column_label}{self.row_label}"
app.py
class App:
def set(self, index, raw):
"""index (Index): the cell to update
raw (str): the raw string
"""
index._replace(val=raw)
Tried the above, but the value for that cell even after assigning it in the set() is still None. What is the best approach to assign a value for that index ?