Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FloatValue:
- def __set_name__(self, cls, name):
- self.name = "_" + name
- def __get__(self, obj, cls):
- return getattr(obj, self.name)
- def __set__(self, obj, val):
- if type(val) != float:
- raise TypeError("Присваивать можно только вещественный тип данных.")
- setattr(obj, self.name, val)
- class Cell:
- value = FloatValue()
- def __init__(self, value = 0.0):
- self.value = value
- class TableSheet:
- def __init__ (self, N, M):
- self.cells = []
- for i in range(N):
- self.temp = []
- for j in range(M):
- self.temp.append(Cell())
- self.cells.append(self.temp)
- table = TableSheet(5, 3)
- counter = 1.0
- for item in table.cells:
- for cell in item:
- cell = Cell(counter)
- counter += 1.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement