3 ms·
Yeah, this is usually the best way for creating singleton in Python. But this makes mocking the singleton module in unit tests harder, as this line is run durin
by sateesh 5y ago
Yeah, this is usually the best way for creating singleton in Python. But this makes mocking the singleton module in unit tests harder, as this line is run during module import itself. If the singleton is making a network connection (say) and you want to mock it for the unit tests, things get clumsy and harder.