code: def connect():
      
      ftp_class = ftplib.FTP if not SSL else ftplib.FTP_TLS
      ftp = ftp_class(timeout=TIMEOUT)
      ftp.connect(HOST, PORT)
      ftp.login(USER, PASSWORD)
      if SSL:
          ftp.prot_p()  # secure data connection
      return ftp
docs: Connect to FTP server, login and return an ftplib.FTP instance.