The other use case for the __new__() method is to create a metaclass to control how a class definition is built. This use of __new__() to build a class object is related to using __new__() to build a new immutable object, shown previously. In both cases, __new__() gives us a chance to make minor modifications in situations where __init__() isn't relevant.
A metaclass is used to build a class. Once a class object has been built, the class object is used to build instance objects. The metaclass of all class definitions is type. The type() function creates the class objects in an application. Additionally, the type() function can be used to reveal the class of an object.
The following is a silly example of building a new, nearly useless class directly with type() as a constructor:
Useless = type("Useless", (), {})
To create a new...