need help on generator...
craig at postnewspapers.com.au
Fri Jan 21 11:34:47 EST 2005
On Fri, 2005-01-21 at 16:54 +0100, Francis Girard wrote:
> 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).
> I'm just trying to understand and obviously I'm missing the point.
( x for x in xrange(10) )
will return a generator that calculates things as it goes, while this:
[ x for x in xrange(10) ]
will return a list.
More information about the Python-list