I was suggested to define a singleton in Python in the following way:
class Controller:
pass
# ...
controller = Controller() However, this way, controller cannot be replaced with a derived class.
What are other sensible ways to define singletons in Python Django?
Maybe, when defining a reusable app, I should not define the singleton instance right in the app, but define it in the program which uses it? What are advantages and disadvantages of doing this?
Aucun commentaire:
Enregistrer un commentaire