def as_singleton_instance(cls):
    """
    This is where the magic happens.  This defines a
    class decorator that returns an *instance* of a class
    with the name "_<original_name>__class" that has
    the same member functions, etc as the cls argument.
    The type of the returned value is not accessible to the
    user (except via the __class__ attribute of the returned
    instance), and therefore no other instances of the class
    can "accidentally" be created.
    """
    new_name = "_{0}__class".format(cls.__name__)
    new_dict = dict(cls.__dict__)
    implicit_bases = (SomeImplicitBase,)
    new_dict['__explicit_bases__'] = cls.__bases__
    new_dict['__implicit_bases__'] = implicit_bases
    all_bases = list(cls.__bases__) + list(implicit_bases)
    rv_type = SingletonMeta(
        new_name,
        tuple(all_bases),
        new_dict
    )
    rv = rv_type()
    return rv

    This is where the magic happens.  This defines a
    class decorator that returns an *instance* of a class
    with the name "_<original_name>__class" that has
    the same member functions, etc as the cls argument.
    The type of the returned value is not accessible to the
    user (except via the __class__ attribute of the returned
    instance), and therefore no other instances of the class
    can "accidentally" be created.
    
recipes/Python/579090_Yet_another_singletpattern_Pythusing_class/recipe-579090.py