def _getSuper (self):
    """
    Gets the `super` object for the class of the currently-executing method.
    """
    frame = sys._getframe().f_back
    code = frame.f_code
    name = code.co_name

    # Find the method we're currently running by scanning the MRO and comparing
    # the code objects. When we find a match, that *might* be the class we're
    # currently in - however, we need to keep searching until we fail to find
    # a match. This is due to the way that methods are created - if you have
    #
    # class A (autosuper):
    #     def test (self):
    #         pass
    #
    # class B (A):
    #     pass
    #
    # then calling getattr(B, 'test') will return A.test, with no way to
    # determine that it's A.test. We only want to use this after calling 
    # getattr(A, 'test') otherwise we will determine the wrong class.

    cur_class = None

    for c in type(self).__mro__:
        try:
            m = getattr(c, name)
            func_code = m.func_code
        except AttributeError:
            func_code = None

        if func_code is code:
            cur_class = c
        elif cur_class is not None:
            break

    if cur_class is None:
        # We could fail to find the class if we're called from a function
        # nested in a method
        raise TypeError, "Can only call 'super' in a bound method"

    return _super(super(cur_class, self), name)

    Gets the `super` object for the class of the currently-executing method.
    
recipes/Python/286195_selfsuper/recipe-286195.py