jackfrued / jackfrued/Python-100-Days
Day09继承和多态@abstractmethod的问题求助
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 187k
- Forks
- 55.8k
- PR merge metrics
- No merged PRs in 30d
Description
我的IDE是Pycharm,在编写Day09继承和多态,猫和狗叫声的那一段代码的时候: @abstractclassmethod
#cls or self?
def make_voice(cls):
pass
"def make_voice(cls)"括号中IDE自动补全的是cls,但是我看文档给出的是self,都可以正常运行,请问有人知道cls和self的区别吗?以及什么时候用cls什么时候用self呢?
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
Start with the Day09 inheritance and polymorphism lesson and inspect the example containing @abstractclassmethod and make_voice(cls). Compare that example with the documentation referenced in the question and identify whether the lesson needs clarification. Done means the lesson explains the distinction consistently and answers when each form applies.
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
- Mostly clear
- Newbie friendliness
- 25/100