mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-27 12:04:00 +03:00
16 lines
401 B
Python
16 lines
401 B
Python
"""`Factory` providers example."""
|
|
|
|
import collections
|
|
|
|
import dependency_injector.providers as providers
|
|
|
|
|
|
User = collections.namedtuple('User', [])
|
|
|
|
# Factory provider creates new instance of specified class on every call.
|
|
users_factory = providers.Factory(User)
|
|
|
|
# Creating several User objects:
|
|
user1 = users_factory() # Same as: user1 = User()
|
|
user2 = users_factory() # Same as: user2 = User()
|