1. Injection happens when you actually access a class attribute (inject.attr), or when you call inject.instance.
python-inject uses one static injector to get dependencies. Some think it cannot be called DI because you
request dependencies, not inject them. In my opinion, it's a matter of terminology.
2. You don't need a prototype scope. Just create any object the way you like. You don't need binder.bind_to_provider(A, A)
# Inject a queue into an email
mailer_queue = inject.attr(MailerQueue)
def __init__(self, to, text):
self.text = text
# Somewhere configure the injector with a MailerQueue binding
inject.configure(lambda: binder.bind(MailerQueue, someQueue))
# Create Email as a normal class (no need for a prototype scope)
# MailerQueue is injected when you access it.
python-inject is simpler. It just injects dependencies.
Feel free to see the source code, it's less then 300 lines.