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)

Metaclasses

In this section, we'll look at metaclasses, which affect the creation of class objects right from the beginning.

Like class decorators, metaclasses are a tool we can use to adjust the basic meaning of a class. In concept though, they're very different. A class decorator takes an already created class and transforms it in some way. A metaclass, on the other hand, can affect how a class is created, how it behaves, and even how classes that inherit from the modified class are created and behave.

To understand metaclasses, first we have to grasp the idea that classes are objects, and more than that, they are instances of another class called type. Whenever we create a new class, we create an instance of type, unless the class has a metaclass, as shown here:

If the class we're creating as a metaclass is specified or inherits a metaclass from its ancestors...