Description
Ensures a class has only one instance and provides a global point of access to it. Often used for shared resources.
Where to use
- Logging drivers. \n
- Database connections. \n
- Configuration settings.
Real World Example
A 'Logger' class where every part of the app writes to the same log file via the same instance.
Code Example
class Singleton:
def __init__(self):
pass
def execute(self):
print('Executing Singleton')
