"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-07 09:19:24.240587
"""

```python
class FallbackExecutor:
    """
    A class for creating a fallback executor that handles errors gracefully.

    Methods:
        execute(function: callable, *args) -> Any:
            Executes the provided function with given arguments.
            If an exception occurs during execution, it attempts to run a fallback method.
    """

    def __init__(self, fallback_function: callable):
        """
        Initialize FallbackExecutor with a fallback function.

        Args:
            fallback_function (callable): The function that acts as a fallback in case of errors.
        """
        self.fallback_function = fallback_function

    def execute(self, function: callable, *args) -> Any:
        """
        Execute the provided function with given arguments and handle exceptions.

        If an exception occurs during execution, it attempts to run the fallback method.

        Args:
            function (callable): The function to be executed.
            *args: Positional arguments to pass to `function`.

        Returns:
            Any: The result of the successful execution or the fallback function.
        """
        try:
            return function(*args)
        except Exception as e:
            print(f"An error occurred: {e}")
            return self.fallback_function(*args)

# Example usage
def divide(a, b):
    """Divide two numbers."""
    return a / b

def safe_divide(a, b):
    """Safe division that returns 0 if the denominator is zero."""
    if b == 0:
        return 0
    return a / b

executor = FallbackExecutor(safe_divide)

# Normal execution
result1 = executor.execute(divide, 10, 2)
print(result1)  # Output: 5.0

# Error recovery execution
result2 = executor.execute(divide, 10, 0)
print(result2)  # Output: 0 (fallback function returned this value)
```