code: def ftp_get(fin_src, fout):
      
      assert fin_src[:6] == 'ftp://', fin_src
      dir_full, fin_ftp = os.path.split(fin_src[6:])
      pt0 = dir_full.find('/')
      assert pt0 != -1, pt0
      ftphost = dir_full[:pt0]
      chg_dir = dir_full[pt0+1:]
      print('FTP RETR {HOST} {DIR} {SRC} -> {DST}'.format(
          HOST=ftphost, DIR=chg_dir, SRC=fin_ftp, DST=fout))
      ftp = FTP(ftphost)  # connect to host, default port      ftp.ncbi.nlm.nih.gov
      ftp.login()         # user anonymous, passwd anonymous@
      ftp.cwd(chg_dir)    # change into "debian" directory     gene/DATA
      cmd = 'RETR {F}'.format(F=fin_ftp)   #                   gene2go.gz
      ftp.retrbinary(cmd, open(fout, 'wb').write)  #           /usr/home/gene2go.gz
      ftp.quit()
docs: Download a file from an ftp server