Le vendredi 21 Janvier 2005 16:06, Craig Ringer a ÃcritÂ: > On Fri, 2005-01-21 at 22:38 +0800, Craig Ringer wrote: > > consecutive_sets = ( x[offset:offset+subset_size] > > for subset_size in xrange(2, len(x)) > > for offset in xrange(0, len(x) + 1 - subset_size) ) > > Where 'x' is list to operate on, as I should've initially noted. Sorry > for the reply-to-self. > > I did say "awful" for a reason ;-) > > -- > Craig Ringer
First, I think that you mean : consecutive_sets = [ x[offset:offset+subset_size] for subset_size in xrange(2, len(x)) for offset in xrange(0, len(x) + 1 - subset_size)] (with square brackets). Second, this is not lazy anymore (like Denis S. Otkidach previous answer was) because the __whole__ list get constructed __before__ any other piece of code have a chance to execute. The type of consecutive_sets is simply a list, not a generator. I'm just trying to understand and obviously I'm missing the point. Thank you Francis Girard FRANCE -- http://mail.python.org/mailman/listinfo/python-list