Pythonic way of implementing getters and setters.
class Person:
@property
def name(self):
- return ' '.join(a if a == 'van' else a.title() for a in self._name)
+ return ' '.join(a.title() for a in self._name)
@name.setter
def name(self, value):
@@ -870,9 +870,9 @@ Z = dataclasses.make_dataclass('Z', [>>> person = Person()
->>> person.name = ' gUiDo VaN rOsSuM '
+>>> person.name = ' jEaN-lUc gOdArD '
>>> person.name
-'Guido van Rossum'
+'Jean-Luc Godard'
Decorator that automatically generates init(), repr() and eq() special methods.
from dataclasses import dataclass, field