mlpy.modules.patterns.RegistryInterface¶
-
class
mlpy.modules.patterns.
RegistryInterface
(name, bases, dct)[source]¶ Bases:
type
Metaclass registering all subclasses derived from a given class.
The registry interface adds every class derived from a given class to its registry dictionary. The registry attribute is a class variable and can be accessed anywhere. Therefore, this interface can be used to find all subclass of a given class.
One use case are factory classes.
Examples
Create a registry class:
>>> from mlpy.modules.patterns import RegistryInterface >>> class MyRegistryClass(object): ... __metaclass__ = RegistryInterface
Note
Attributes
registry (list) List of all classes deriving from a registry class. Methods
__init__
(name, bases, dct)Register the deriving class on instantiation.