Complete the code to declare the abstraction class with a bridge to the implementation.
class Abstraction: def __init__(self, [1]): self.implementation = implementation
The abstraction class holds a reference to the implementation object, usually named implementation.
Complete the code to define the implementation interface method.
class Implementation: def [1](self): pass
The implementation interface defines the operation method that concrete implementations must override.
Fix the error in the refined abstraction method calling the implementation.
class RefinedAbstraction(Abstraction): def operation(self): return self.[1].operation()
The refined abstraction calls the operation method on the implementation attribute.
Fill both blanks to complete the concrete implementation class and its operation method.
class ConcreteImplementation[1](Implementation): def operation(self): return '[2] implementation result'
The concrete implementation class is named ConcreteImplementationA and returns a string indicating its result.
Fill all three blanks to create a client code that uses the bridge pattern.
impl = ConcreteImplementation[1]() abstraction = RefinedAbstraction([2]) result = abstraction.[3]() print(result)
The client creates a ConcreteImplementationA instance, passes it to RefinedAbstraction, calls operation, and prints the result.