Skip to content

Commit 17bf278

Browse files
committed
第八章8.6及8.8更改
1 parent 5183ccf commit 17bf278

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

source/c08/p06_create_managed_attributes.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Properties还是一种定义动态计算attribute的方法。
154154
155155
@property
156156
def diameter(self):
157-
return self.radius ** 2
157+
return self.radius * 2
158158
159159
@property
160160
def perimeter(self):

source/c08/p08_extending_property_in_subclass.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
----------
100100
在子类中扩展一个property可能会引起很多不易察觉的问题,
101101
因为一个property其实是 ``getter``、``setter`` 和 ``deleter`` 方法的集合,而不是单个方法。
102-
因此,但你扩展一个property的时候,你需要先确定你是否要重新定义所有的方法还是说只修改其中某一个。
102+
因此,当你扩展一个property的时候,你需要先确定你是否要重新定义所有的方法还是说只修改其中某一个。
103103

104104
在第一个例子中,所有的property方法都被重新定义。
105105
在每一个方法中,使用了 ``super()`` 来调用父类的实现。
@@ -135,7 +135,7 @@
135135
.. code-block:: python
136136
137137
class SubPerson(Person):
138-
@Person.getter
138+
@Person.name.getter
139139
def name(self):
140140
print('Getting name')
141141
return super().name

0 commit comments

Comments
 (0)