Skip to content

Update p21_avoid_repetitive_property_methods.rst #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/c09/p21_avoid_repetitive_property_methods.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
看上去有点难理解,其实它所做的仅仅就是为你生成属性并返回这个属性对象。
因此,当在一个类中使用它的时候,效果跟将它里面的代码放到类定义中去是一样的。
尽管属性的 ``getter`` 和 ``setter`` 方法访问了本地变量如 ``name`` , ``expected_type``
以及 ``storate_name`` ,这个很正常,这些变量的值会保存在闭包当中。
以及 ``storage_name`` ,这个很正常,这些变量的值会保存在闭包当中。


我们还可以使用 ``functools.partial()`` 来稍稍改变下这个例子,很有趣。例如,你可以像下面这样:
Expand Down