Español
Abrir en Telegram

Hiloкому надо сломать - сломает

8 mensajes · –
    1. R
      зачем падать. вот тебе good_singleton. class Singleton(type): """ Singleton implementation. Example of usage: >>> class MyClass(metaclass=Singleton): ... pass >>> instance1 = MyClass() >>> instance2 = MyClass() >>> instance1 is instance2 # True """ _instances: dict[type, Any] = {} def __call__(cls, *args: Any, **kwargs: Any) -> Any: if cls not in cls._instances: cls._instances[cls] = super().__call__(*args, **kwargs) return cls._instances[cls]
        1. R
          class Singleton(type): _instances: dict[type, Any] = {} def __call__(cls, *args: Any, **kwargs: Any) -> Any: if cls not in cls._instances: cls._instances[cls] = super().__call__(*args, **kwargs) return cls._instances[cls] raise AssertionError(f"Cannot initialize more than one instance of class {cls.__name__}")
ССообщество Python ПрограммистовСообщество Python Программистов@python_scripts · grupo · Tecnología
4 169miembros43escriben en 30 días
Feed de la comunidad Abrir en Telegram

Un feed público abierto del índice de búsqueda ChatCrawler — el “Google del Telegram público”; se actualiza a medida que se rastrea la comunidad. Las horas se muestran en UTC.

Solo contenido público, API oficial de Telegram. Acerca de · Preguntas frecuentes · Límites del índice · Eliminar una página · Catálogo · Búsqueda · Cómo contamos