-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
This issue describes how to implement the class-inheritance concept docs.
Getting started
Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:
- Contributing to Exercism | Exercism and GitHub | - Contributor Pull Request Guide
- What are those Weird Task Tags about?
- Building Language Tracks: An Overview
- What are Concepts?
- Concept Specifications
- Exercism Formatting and Style Guide
- Exercism Markdown Specification
- Reputation
Goal
This concept is meant to teach an understanding/use of class-inheritance in Python.
Learning objectives
- more fully understand the uses (and possible abuses) of
classesin Python - understanding and use of
single inheritancein Python - understanding and use of
multiple inheritancein Python- the diamond inheritance problem
- Pythons MRO (method resolution order)
- pros and cos of
mixins() to isolatemultiple inheritanceissues
- when and when not to use
__super__()to call a parentclassconstructor
Out of scope
class-compositionas an explicit topic (it is ok to use limited composition as needed in example code)dataclassesdecoratorsoutside of@property,@staticmethod, and@classmethod(the student should already be exposed to these in the prerequisite exercise)generatorscoroutinesdescriptors(these will get their own exercise)- using a
classas a decorator - performance considerations
Concepts
classesinheritanceinOOPsingle inheritancemultiple inheritanceminxins__super__()
Prerequisites
These are the concepts/concept exercises the student needs to complete/understand before solving the concept exercise that these concept documents support.
basicsbooleansclassesclass-customizationcomparisonsdecoratorsdictsfunctionshigher-order-functionsiterationlistsnumberssequencessetsstringstuples
Resources to refer to
- classes (Python tutorial)
- Real Python: Object-Oriented Programming in Python 3
- Real Python: Inheritance and Composition: A Python OOP Guide
- Towards DataScience: Understand Inheritance in Python -- (this is not a good resource for hints or links, since it requires an account signup)
- Multiple Inheritance in Python
- Multiple Inheritance is Hard (Ned Batchelder)
- Python.org: MRO in Python 2.3+
- Dig into Python super() and MRO
- Multiple inheritance and mixin classes in Python
- Making Python classes more modular using mixins
- Write composable, reusable Python classes using Mixinsl)
- Mixins in Python and Ruby Compared
- Python Data Model - Python Docs
-
links.jsonFor more information, see concept links file
- The same resources listed in this issue can be used as a starting point for the
concepts/links.jsonfile, if it doesn't already exist. - If there are particularly good/interesting information sources for this concept that extend or supplement the concept exercise material & the resources already listed -- please add them to the
links.jsondocument.
- The same resources listed in this issue can be used as a starting point for the
Concept Description
Please see the following for more details on these files: concepts
-
Concept
about.mdFor more information, see Concept
about.md- This file provides information about this concept for a student who has completed the corresponding concept exercise. It is intended as a reference for continued learning.
-
Concept
introduction.mdFor more information, see Concept
introduction.md- This can also be a summary/paraphrase of the document listed above, and will provide a brief introduction of the concept for a student who has not yet completed the concept exercise. It should contain a good summation of the concept, but not go into lots of detail.
Implementation Notes
- Example code should only use syntax & concepts introduced within these docs or one of the prerequisite concept exercises or documents.
Please do not use comprehensions, generator expressions, or other syntax not previously covered. Please also follow PEP8 guidelines. - Our markdown and JSON files are checked against prettier . We recommend setting prettier up locally and running it prior to submitting your PR to avoid any CI errors.
Help
If you have any questions while implementing the exercise, please post the questions as comments in this issue, or contact one of the maintainers on our Slack channel.