"""Create fallback_executor
Generated by Phi-Octopus Eden
2025-11-07 16:16:55.694594
"""

```python
from typing import Callable, Any, Optional


class FallbackExecutor:
    """
    A class that provides a fallback mechanism for executing functions.

    If an exception occurs during the execution of the primary function,
    it attempts to execute the fallback function.
    """

    def __init__(self, primary_function: Callable[..., Any], fallback_function: Callable[..., Any]):
        """
        Initializes FallbackExecutor with both the primary and fallback functions.

        :param primary_function: The main function to try executing.
        :param fallback_function: The function to execute if an exception occurs in the primary function.
        """
        self.primary_function = primary_function
        self.fallback_function = fallback_function

    def __call__(self, *args: Any, **kwargs: Any) -> Optional[Any]:
        """
        Executes the primary function. If an exception is raised,
        attempts to execute the fallback function.

        :param args: Positional arguments passed to the functions.
        :param kwargs: Keyword arguments passed to the functions.
        :return: The result of the successfully executed function or None if both fail.
        """
        try:
            return self.primary_function(*args, **kwargs)
        except Exception as e:
            print(f"Primary function failed with error: {e}")
            try:
                return self.fallback_function(*args, **kwargs)
            except Exception as f_e:
                print(f"Fallback function also failed with error: {f_e}")
                return None


# Example usage
def divide(a: int, b: int) -> float:
    """
    Divides two numbers.
    """
    return a / b


def safe_divide(a: int, b: int) -> Optional[float]:
    """
    Safe division that returns 0 if the divisor is zero.
    """
    try:
        return divide(a, b)
    except ZeroDivisionError:
        return 0.0


fallback_executor = FallbackExecutor(divide, safe_divide)

# Test cases
result1 = fallback_executor(10, 2)  # Should be 5.0
print(f"Result: {result1}")

result2 = fallback_executor(10, 0)  # Primary function will fail due to ZeroDivisionError,
                                    # Fallback will return 0.0
print(f"Result: {result2}")
```