Re: Generator (re-)definition within a loop

2010-06-21 Thread Terry Reedy
On 6/21/2010 3:29 AM, Pierre Reinbold wrote: On 06/18/2010 11:48 PM, Terry Reedy wrote: Let's apply Reedy's Rule: when you have trouble understanding a function expression, replace it with the (near) equivalent def statement. (Among other advantages, one can insert print calls!) Genexps, lik

Re: Generator (re-)definition within a loop

2010-06-21 Thread Thomas Jollans
On 06/21/2010 09:29 AM, Pierre Reinbold wrote: > [snip] > > Another try to avoid infinite recursion: > > def badgen_product2(*args, **kwds): > pools = map(tuple, args) > result = [[]] > for pool in pools: > def augments(): > for x in result: This line is executed w

Re: Generator (re-)definition within a loop

2010-06-21 Thread Pierre Reinbold
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 06/18/2010 11:48 PM, Terry Reedy wrote: > On 6/18/2010 3:57 PM, Pierre Reinbold wrote: > >> def genexp_product(*args): >> pools = map(tuple, args) >> result = [[]] >> for pool in pools: >> result = (x+[y] for x in result for

Re: Generator (re-)definition within a loop

2010-06-18 Thread Terry Reedy
On 6/18/2010 3:57 PM, Pierre Reinbold wrote: Hi all, This is my first post on the list. I'm mainly a sysadmin and no expert in programming languages, so this may be a stupid question no but it puzzles me. I was pondering on the documentation of the function product(*args, **kwds) in the ite

Generator (re-)definition within a loop

2010-06-18 Thread Pierre Reinbold
Hi all, This is my first post on the list. I'm mainly a sysadmin and no expert in programming languages, so this may be a stupid question but it puzzles me. I was pondering on the documentation of the function product(*args, **kwds) in the itertools module. It is said that: This function is equi