An instance of this class represents a single cell in a :class:`~gspread.worksheet.Worksheet`.
| 12 | |
| 13 | |
| 14 | class Cell: |
| 15 | """An instance of this class represents a single cell |
| 16 | in a :class:`~gspread.worksheet.Worksheet`. |
| 17 | """ |
| 18 | |
| 19 | def __init__(self, row: int, col: int, value: Optional[str] = "") -> None: |
| 20 | self._row: int = row |
| 21 | self._col: int = col |
| 22 | |
| 23 | #: Value of the cell. |
| 24 | self.value: Optional[str] = value |
| 25 | |
| 26 | @classmethod |
| 27 | def from_address(cls, label: str, value: str = "") -> "Cell": |
| 28 | """Instantiate a new :class:`~gspread.cell.Cell` |
| 29 | from an A1 notation address and a value |
| 30 | |
| 31 | :param string label: the A1 label of the returned cell |
| 32 | :param string value: the value for the returned cell |
| 33 | :rtype: Cell |
| 34 | """ |
| 35 | row, col = a1_to_rowcol(label) |
| 36 | return cls(row, col, value) |
| 37 | |
| 38 | def __repr__(self) -> str: |
| 39 | return "<{} R{}C{} {}>".format( |
| 40 | self.__class__.__name__, |
| 41 | self.row, |
| 42 | self.col, |
| 43 | repr(self.value), |
| 44 | ) |
| 45 | |
| 46 | def __eq__(self, other: object) -> bool: |
| 47 | if not isinstance(other, Cell): |
| 48 | return False |
| 49 | |
| 50 | same_row = self.row == other.row |
| 51 | same_col = self.col == other.col |
| 52 | same_value = self.value == other.value |
| 53 | return same_row and same_col and same_value |
| 54 | |
| 55 | @property |
| 56 | def row(self) -> int: |
| 57 | """Row number of the cell. |
| 58 | |
| 59 | :type: int |
| 60 | """ |
| 61 | return self._row |
| 62 | |
| 63 | @property |
| 64 | def col(self) -> int: |
| 65 | """Column number of the cell. |
| 66 | |
| 67 | :type: int |
| 68 | """ |
| 69 | return self._col |
| 70 | |
| 71 | @property |
no outgoing calls
no test coverage detected
searching dependent graphs…