code: def build_opener(*handlers):
      
      def isclass(obj):
          return isinstance(obj, type) or hasattr(obj, "__bases__")
  
      opener = OpenerDirector()
      default_classes = [ProxyHandler, UnknownHandler, HTTPHandler,
                         HTTPDefaultErrorHandler, HTTPRedirectHandler,
                         FTPHandler, FileHandler, HTTPErrorProcessor]
      if hasattr(http_client, "HTTPSConnection"):
          default_classes.append(HTTPSHandler)
      skip = set()
      for klass in default_classes:
          for check in handlers:
              if isclass(check):
                  if issubclass(check, klass):
                      skip.add(klass)
              elif isinstance(check, klass):
                  skip.add(klass)
      for klass in skip:
          default_classes.remove(klass)
  
      for klass in default_classes:
          opener.add_handler(klass())
  
      for h in handlers:
          if isclass(h):
              h = h()
          opener.add_handler(h)
      return opener
docs: Create an opener object from a list of handlers.
  
      The opener will use several default handlers, including support
      for HTTP, FTP and when applicable HTTPS.
  
      If any of the handlers passed as arguments are subclasses of the
      default handlers, the default handlers will not be used.