From 250d693e126439de93af719be7ddd042d29e264b Mon Sep 17 00:00:00 2001 From: Supravisor <153783117+Supravisor@users.noreply.github.com> Date: Fri, 14 Feb 2025 12:18:07 +1300 Subject: [PATCH] fix(curriculum): include an example of a decorator (#58753) Co-authored-by: Dario-DC <105294544+Dario-DC@users.noreply.github.com> --- .../662f96576ef178927de87975.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-interfaces-by-building-an-equation-solver/662f96576ef178927de87975.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-interfaces-by-building-an-equation-solver/662f96576ef178927de87975.md index dd06ade6f6c..fc495352ac7 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-interfaces-by-building-an-equation-solver/662f96576ef178927de87975.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-interfaces-by-building-an-equation-solver/662f96576ef178927de87975.md @@ -9,6 +9,14 @@ dashedName: step-7 In order to be recognized as an abstract method, a method should be decorated with the `@abstractmethod` decorator. +A decorator is used in Python to modify the behavior of a function. Here's an example of how to use a decorator named `spam`: + +```py +@spam +def foo(): + pass +``` + Modify your import statement to import the `abstractmethod` decorator and decorate both the `solve` and `analyze` methods of the `Equation` class. This will raise two exceptions. Once a class inheriting from `ABC` has an abstract method, the class cannot be instantiated anymore. Therefore, delete the `Equation` instance to get rid of the error.