Gerard Flanagan wrote: > > just variations on previous answers: > > rng = range(1,101) > > #ad hoc > for line in ( rng[i:i+5] for i in xrange(0,100,5) ): > print ' '.join(map(str,line)) > > #in general > def lines( seq, count=1 ): > n = len(seq) > for x in ( seq[i:i+count] for i in xrange(0,n,count) ): > yield x >
Don't those last two lines deflate to: for i in xrange(0,n,count): yield seq[i:i+count] ??? -- http://mail.python.org/mailman/listinfo/python-list