In Ruby I like to use a lightweight class that standardizes my calling convention so that .new builds a new object with default dependencies and all runtime parameters are passed to a single public method called .call
class Service
def self.call(*args, &block)
new.call(*args, &block)
end
end
Then, I can define my new objects in such a way that I inject dependencies in the constructor and that they have a single public method called .call and call its dependencies there.
class Something < Service
def initialize(something: Something, anything: Anything)
@something = something
@anything = anything
end
def call(arg1:, arg2:)
result_a = @a.call(...)
result_b = @b.call(...)
end
end
How can I achieve the same effect in Python?