mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-22 21:08:12 +08:00
fix(curriculum): include an example of a decorator (#58753)
Co-authored-by: Dario-DC <105294544+Dario-DC@users.noreply.github.com>
This commit is contained in:
parent
a03317a702
commit
250d693e12
@ -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 <dfn>decorator</dfn> 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.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user