deepaugment/lib/decorators.py
def singleton(cls):
    """Decorator makes sure the class it is decorating wont
    be instantiated more than once

    A usage example:
        @singleton
        class AnyClass:
            ...

    If/when the class called for second time, previous (single)
    instance will be returned

    Inspiration of the decorator comes from:
    https://www.python.org/dev/peps/pep-0318/#examples

    """

    instances = {}

    @wraps(cls)
    def wrapper():
        if cls not in instances:
            instances[cls] = cls()
        return instances[cls]

    return wrapper
Decorator makes sure the class it is decorating wont
    be instantiated more than once

    A usage example:
        @singleton
        class AnyClass:
            ...

    If/when the class called for second time, previous (single)
    instance will be returned

    Inspiration of the decorator comes from:
    https://www.python.org/dev/peps/pep-0318/#examples

    
Decorator makes sure the class it is decorating wont
be instantiated more than once

A usage example:
@singleton
class AnyClass.

If/when the class called for second time, previous (single)
instance will be returned


Decorator makes sure the class it is decorating wont be instantiated more than once A usage example : @singleton class AnyClass . If / when the class called for second time previous ( single ) instance will be returned
def singleton(cls):
    instances = {}
    @wraps(cls)
    def wrapper():
        if cls not in instances:
            instances[cls] = cls()
        return instances[cls]
    return wrapper
def singleton ( cls ) : instances = { } @ wraps ( cls ) def wrapper ( ) : if cls not in instances : instances [ cls ] = cls ( ) return instances [ cls ] return wrapper
Decorator makes sure the class it is decorating wont
be instantiated more than once
Decorator makes sure the class it is decorating wont be instantiated more than once
"""Decorator makes sure the class it is decorating wont
    be instantiated more than once

    A usage example:
        @singleton
        class AnyClass:
            ...

    If/when the class called for second time, previous (single)
    instance will be returned

    Inspiration of the decorator comes from:
    https://www.python.org/dev/peps/pep-0318/#examples

    """
cls