jackfrued / jackfrued/Python-100-Days
day9有个疑问:面对对象中为什么要对属性限制访问呢?
Open
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 187k
- Forks
- 55.8k
- PR merge metrics
- No merged PRs in 30d
Description
萌新有个疑问,希望大佬能解释一下:在Persons类中,先是利用self._name对name进行限制访问,无法person.name访问属性,为什么后面又使用@property装饰器来实现person.name来访问对象?绕了一圈限制访问的意义何在?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the Day 9 lesson's Persons example and the surrounding explanation of _name and @property. Clarify why direct attribute access is restricted and what property access provides; done means the lesson answers this question without requiring readers to infer the distinction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100