A repository to teach Python decorators.
By definition the decorators are functions that transform the behavior of other functions without explicitly modifying them.
ex:
class Example:
@classmethod
def foo(cls):
pass
Without the @classmethod
decorator, the foo
method would be connected to the attribute. With the decorator, the method have it's behavior changed to be connected to the class instead of the object.
Describe decorators syntax and the process of creating and using on:
See motivation notebook to see examples of why decorators
were created.
Then see:
This link will get you to built-in methods. As you'll understand in this repository, built-in decorators are created from built-in methods.
This link will guide you to the fun documentation about Python C3 methods resolution order. Even if is confusing, see the beautiful Python snake created. :)
This document is intended for Python programmers who want to understand the C3 Method Resolution Order used in Python 2.3. Although it is not intended for newbies, it is quite pedagogical with many worked out examples. I am not aware of other publicly available documents with the same scope, therefore it should be useful.
This link will guide you to the beautiful pattern explanation about decorators and how they change methods dynamically.
You'll find:
- Applicability
- Consequences
- Metapatterns
This link will guide you to a Real Python tutorial about decorators.
[...] Explicit is better than implicit. [...] Simple is better than complex. [...] Readability counts. (PEP 20)