Skip to content

Instantly share code, notes, and snippets.

@rec
Last active April 11, 2021 14:32
Show Gist options
  • Save rec/7fb22cb5733a2af2e6bb6fd589ab71b7 to your computer and use it in GitHub Desktop.
Save rec/7fb22cb5733a2af2e6bb6fd589ab71b7 to your computer and use it in GitHub Desktop.
from dataclasses import dataclass, field
@dataclass(order=True)
class Action:
name: str = 'test'
_name: str = field(default="undefined", init=False, compare=True, repr=False)
@property
def name(self) -> str: # pylint: disable=function-redefined
return self._name
@name.setter
def name(self, name: str) -> None:
self._name = name
print(Action('TEST').name)
print(Action().name)
# prints something like
# TEST
# <property object at 0x10fe6e950>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment