Python OOP and Modules/Property getter/setter

Property getter/setter

Section: Inheritance and protocols

Property getter/setter

python
python
class Celsius:
    def __init__(self, value: float):
        self._value = value

    @property
    def value(self) -> float:
        return self._value

    @value.setter
    def value(self, new_value: float):
        self._value = new_value

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Inheritance and protocols
Subclass
Subclass
OpenIn sheetpythonsame section
ABC abstract method
ABC abstract method
OpenIn sheetpythonsame section
Call super
Call super
OpenIn sheetpythonsame section
Basic class
Basic class
OpenIn sheetpython1 tag match
Class method
Class method
OpenIn sheetpython1 tag match
Static method
Static method
OpenIn sheetpython1 tag match