I wonder really, if the Python language itself can express an elegant flat solution to turn the block delivering callback function into a generator/.read(bytes) solution? I found no way.
(Looking over some Ruby stuff, Ruby seems to be able to do so from the language. I am not really familiar to Ruby. I always felt Python to be as complete - but much more clean. I became somewhat jealous ... :-) )
As the solution in my case has to stand many different file systems compatibly ( file.read(bytes) function !) and also other FTPS & SFTP classes with different retrbinary functions have to be compatible, I cannot even make a simple FTP subclassed retrbinary without getting really weired. Thus the existing .retrbinary with callback is the "official interface in this game".
> >> def callback(self, data): > >> self.offset = self.offset + len(data) > >> self.data = data > >> ## now quit the RETR command? > >> raise TransferAbort("stop right now") -- http://mail.python.org/mailman/listinfo/python-list