mlpy.modules.patterns.Singleton

class mlpy.modules.patterns.Singleton[source]

Bases: type

Metaclass ensuring only one instance of the class exists.

The singleton pattern ensures that a class has only one instance and provides a global point of access to that instance.

See also

Borg

Notes

To define a class as a singleton include the __metaclass__ directive.

Examples

Define a singleton class:

>>> from mlpy.modules.patterns import Singleton
>>> class MyClass(object):
>>>     __metaclass__ = Singleton

Note

Project: Code from StackOverflow.
Code author: theheadofabroom
License: CC-Wiki

Methods

__call__(*args, **kwargs) Returns instance to object.