English
Open in Telegram

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

8 messages · –
    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 · group · Tech
4 169members43writing in 30 days
Venue feed Open in Telegram

An open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · Index limits · Remove a page · Catalog · Search · How we count