Is it reasonable to use a decorator to instantiate a singleton in Python?

Published: 5/10/2017
Is it reasonable to use a decorator to instantiate a singleton in Python?
Source: SOFTWAREENGINEERING.STACKEXCHANGE.COM

Suppose I have a class like this: class Foo(object): # some code here As it happens, Foo is a singleton. There are numerous ways to write singletons in Python, but most of them don't really feel very Pythonic to me. If someone else has a particularly strong reason for instantiating or subclassing my class, I see no reason to go out of my way to make things unreasonably difficult for them (beyond

Read more
Related news
Comment