title: Python FTP "chunk" iterator (without loading entire file into memory)
body: <p>There are several answers on stack overflow about retrieving a FTP file and writing it to a stream such as a string buffer or a file which can then be iterated on.</p>
  
  <p>Such as: <a href="https://stackoverflow.com/questions/18772703/read-a-file-in-buffer-from-ftp-python">Read a file in buffer from FTP python</a></p>
  
  <p>However, these solutions involve loading the entire file into memory or downloading it to the disk before beginning to process the contents. </p>
  
  <p>I do not have enough memory to buffer the whole file and I do not have access to the disk. This can be done by processing the data in the callback function, but <strong>I want to know if it's possible to wrap the ftp code</strong> in some magic that returns an iterator rather than peppering my code with callbacks.</p>
  
  <p>I.E. rather than:</p>
  
  <pre><code>def get_ftp_data(handle_chunk):
      ...
      ftp.login('uesr', 'password') # authentication required
      ftp.retrbinary('RETR etc', handle_chunk)
      ...
  
  get_ftp_data(do_stuff_to_chunk)
  </code></pre>
  
  <p><strong>I want:</strong></p>
  
  <pre><code>for chunk in get_ftp_data():
      do_stuff_to_chunk(chunk)
  </code></pre>
  
  <p>And (unlike existing answers) I want to do it without writing the entire ftp file to disk or memory before iterating on it.</p>