print way [ [ [ [ [ [ in [ ]len(list(make_change( ))out[ ] generator expresssions simple way to make generator is by using generator expression this is generator analogue to listdict and set comprehensionsto create oneenclose what would otherwise be list comprehension with parenthesis instead of bracketsin [ ]gen ( * for in xrange( )in [ ]gen out[ ]at this is completely equivalent to the following more verbose generatordef _make_gen()for in xrange( )yield * gen _make_gen(generator expressions can be used inside any python function that will accept generatorin [ ]sum( * for in xrange( )out[ ] in [ ]dict((ii ** for in xrange( )out[ ]{ itertools module the standard library itertools module has collection of generators for many common data algorithms for examplegroupby takes any sequence and functionthis groups consecutive elements in the sequence by return value of the function here' an examplein [ ]import itertools in [ ]first_letter lambda xx[ in [ ]names ['alan''adam''wes''will''albert''steven'in [ ]for letternames in itertools groupby(namesfirst_letter)print letterlist(namesnames is generator ['alan''adam'functions www it-ebooks info