import functools def singleton(cls): cls._instance = None @functools.wraps(cls) def wrapper_singleton(*args, **kwargs): if not cls._instance: cls._instance = cls(*args, **kwargs) return cls._instance return wrapper_singleton
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter