diff --git a/README.md b/README.md index 5f96c80..cec86db 100644 --- a/README.md +++ b/README.md @@ -1017,7 +1017,7 @@ class C(A, B): pass 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): @@ -1026,9 +1026,9 @@ class Person: ```python >>> person = Person() ->>> person.name = ' gUiDo VaN rOsSuM ' +>>> person.name = ' jEaN-lUc gOdArD ' >>> person.name -'Guido van Rossum' +'Jean-Luc Godard' ``` ### Dataclass diff --git a/index.html b/index.html index c08e59e..2ecdbd4 100644 --- a/index.html +++ b/index.html @@ -861,7 +861,7 @@ Z = dataclasses.make_dataclass('Z', [

Property

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'
 

Dataclass

Decorator that automatically generates init(), repr() and eq() special methods.

from dataclasses import dataclass, field