Book Image

Daniel Arbuckle's Mastering Python

By : Daniel Arbuckle
Book Image

Daniel Arbuckle's Mastering Python

By: Daniel Arbuckle

Overview of this book

Daniel Arbuckle's Mastering Python covers the basics of operating in a Python development environment, before moving on to more advanced topics. Daniel presents you with real-world solutions to Python 3.6 and advanced-level concepts, such as reactive programming, microservices, ctypes, and Cython tools. You don't need to be familiar with the Python language to use this book, as Daniel starts with a Python primer. Throughout, Daniel highlights the major aspects of managing your Python development environment, shows you how to handle parallel computation, and helps you to master asynchronous I/O with Python 3.6 to improve performance. Finally, Daniel will teach you the secrets of metaprogramming and unit testing in Python, helping you acquire the perfect skillset to be a Python expert. Daniel will get you up to speed on everything from basic programming practices to high-end tools and techniques, things that will help set you apart as a successful Python programmer.
Table of Contents (13 chapters)

Class decorators

In this section, we'll look at class decorators, which are conceptually similar to function decorators but open different doors.

Class decorators work in the same basic way that function decorators do. A class decorator receives the class as its only parameter, and whatever it returns replaces that class. This is illustrated in the following image:

The return value doesn't have to be the same class or even a class at all, but it should be something that is meaningful. When it's bound to the class's name, it's rarely useful for a decorator to return none.

Also, like a function decorator, a class decorator can modify the attributes of the class or enclose the whole class in wrapper code. However, modifying the attributes of the class is effectively the same as modifying the class of the source code. This means that unlike functions, a class...