Using the creator module
The first powerful tool provided by the DEAP framework is the creator
module. The creator
module is used as a meta-factory, and it enables us to extend existing classes by augmenting them with new attributes.
For example, suppose we have a class called Employee
. Using the creator
tool, we can extend the Employee
class by creating a Developer
class, as follows:
from deap import creator creator.create("Developer", Employee,\ position="Developer", \ programmingLanguages=set)
The first argument that’s passed to the create()
function is the desired name for the new class. The second argument is the existing base class to be extended. Then, each additional argument defines an attribute for the new class. If the argument is assigned a data structure...