#NEWLINE# def product( * args , **kwds ) : #NEWLINE# #INDENT# pools = ( map ( tuple , args ) * kwds . get ( 'repeat' , 1 ) ) #NEWLINE# result = [ [ ] ] #NEWLINE# for pool in pools : #NEWLINE# #INDENT# result = [ ( x + [ y ] ) for x in result for y in pool ] #NEWLINE# #UNINDENT# for prod in result : #NEWLINE# #INDENT# ( yield tuple ( prod ) )