singleton class

    0

    4

    zhongjian-ls

     def to_singleton(self):
    if self.__instance is not None:
     return self.__instance
    return super(SingletoCls, self).
    
    class SingletoCls:
      """
      创建单实例类 "SingletoCls"
      """
      __instance = None
    
      def __new__(cls, *args, **kwargs):
        if cls.__instance:
          return cls.__instance
        else:
          return object.__new__(cls, *args, **kwargs)
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.