Introduction

Decorators in Python are any callable objects that can modify a function or class. They allow some additional functionality similar to other languages, such as declaring a method as a class or static method.

A class method is one that is called on a class rather than a particular instance. A static method is similar, but would be applied to all instances of a class, not just a specific instance. An instance method is the traditional method when dealing with OOP in Python. 

When a call to a function or a class is made, it is passed to a decorator and the decorator returns a modified function/class. These modified objects generally include calls to the originally called object.

In this chapter, decorators can be used with functions and methods, but usually only the term functions will be used for brevity. Method will be used when explicitly talking about classes.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset