-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
This issue describes how to implement the class-customization concept docs.
You can find the related concept exercise issue here
If you have not yet contributed to concept documents, this issue will require some upfront reading to give you the needed background knowledge.
✅ Getting started
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.
General Contributing Docs:
- Contributing to Exercism | Exercism and GitHub | - Contributor Pull Request Guide
- What are those Weird Task Tags about?
- Exercism Formatting and Style Guide
- Exercism Markdown Specification
- Reputation
Documents on Language Tracks and Concepts:
🎯 Goal
These concept documents are meant to teach an understanding/use of class-customization in Python.
💡 Learning objectives
-
more fully understand the uses (and possible abuses) of
classesin Python -
understanding of
class members -
understand some of the options that can be used to adapt a
classfor purposes beyond simpleobjectcreation, including:- using
@staticmethodto provide namespaced functionality withoutobjectinstantiation. - using
@classmethodto provide functionality that modifiesclassattributes shared acrossclass instances - using
__repr__()and__str__()to provide human-readable and understandable class descriptions.
- using
-
using
property()and@propertyto make getters and setters for the methods of aclass- using
property()and@propertyto "compose" or "calculate" and returninstance attributes. - using
property()and@propertyto "protect" an attribute from mutation.
- using
-
using
functools.cached_property()to calculate a property via a method, and the cache it for future calls to the property. -
Pythons version of "non-public" methods and "private variables" (AKA
Name mangling)
🚫 Out of scope
Concepts and Subjects that are Out of Scope
class-inheritance,multiple-inheritance,__super()__, classmixinsclass-composition-- (beyond the composition needed for the decorators in this exercise)dataclassesdecoratorsoutside of@property,@staticmethod, and@classmethod(the student should already be exposed to the function version of these in a prerequisite)generatorscoroutinesdescriptors(these will get their own exercise)- using a
classas a decorator - performance considerations
🤔 Concepts
Concepts and Related Concepts this Concept Covers
classesclass attributesclass membersclass methods,@classmethodstatic methods,@staticmethoddecoratorsgetters&setters(through the use ofproperty()and@property)instance attributesinstance methodsnon-public methods,private variables, andname-mangling
↩️ Prerequisites
These are the concepts/concept exercises the student should be familiar with before taking on/learning this concept.
Prereqs
basicsbooleansclassescomparisonsdecoratorsdictsfunctionshigher-order-functionsiterationlistsnumberssequencessetsstringstuples
📚 Resources to refer to
Resources
📁 Files to Be Created
File Detail for this Exercise
|
Please see the following for more details on these files: concepts
|
🎶 Implementation Notes
- Example code should only use syntax & concepts introduced within these docs or one of the prerequisite concept exercises or documents. Where possible, please use REPL formatting, unless you are demonstrating pseudo code or a long code block.
Please do not use syntax not previously covered in prerequisite topics or exercises. 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.
🆘 Next Steps & Getting Help
If you'd like to work on this issue, comment saying "I'd like to work on this"(there is no real need to wait for a response, just go ahead, we'll assign you and put a[claimed]label on the issue).- If you have any questions while implementing, please post the questions as comments in here, or contact one of the maintainers on our Slack channel.