| Start | ||||
|---|---|---|---|---|
| Generating metadata using a class decorator This time we are going to declare a class decorator that will add some metadata to a class when we applied to it: We can then apply the class decorator: The decorator is applied when the class is declared not when we create instances of the class. This means that the metadata is shared across all the instances of a class: |
||||
| Passing arguments to a class decorator We can wrap a class decorator with another function to allow customization: The We can then invoke the decorator passing some configuration values: We can use the following function to access the generated metadata: If everything went right the console should display: |
||||
| Basic class decorator A class decorator is just a function that takes the class as its only argument and returns it after doing something with it: We can then apply the class decorator to a class: Parameters
|
Read Article
https://develop.horje.com/learn/1434/reference