In <[EMAIL PROTECTED]>, 人言落日是天涯,望极天涯不见家 wrote:
> I make a sample here for the more clearly explanation > > s = " ..... - this is a large string data - ......." > > def parser1(data) > # do some parser > ... > # pass the remainder to next parser > parser2(data[100:]) > > def parser2(data) > # do some parser > ... > # pass the remainder to next parser > parser3(data[100:]) > > def parser3(data) > # do some parser > ... > # pass the remainder to next parser > parser4(data[100:]) > > ... Do you need the remainder within the parser functions? If not you could split the data into chunks of 100 bytes and pass an iterator from function to function. Untested: def iter_chunks(data, chunksize): offset = chunksize while True: result = data[offset:offset + chunksize] if not result: break yield result def parser1(data): chunk = data.next() # ... parser2(data) def parser2(data): chunk = data.next() # ... parser3(data) # ... def main(): # Read or create data. # ... parser1(iter_chunks(data, 100)) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list