code: def global_instance(cls, cmdline_args, allow_override=False):
          
          orig_value = cls._instance
          assert (orig_value is None) or allow_override
          new_value = None
          try:
              new_value = CmdlineParser(cmdline_args)
              cls._instance = new_value
              yield new_value
          finally:
              assert cls._instance is new_value
              cls._instance = orig_value
docs: Meant to be used as a context manager.