Re: Generator question

2019-03-14 Thread Pierre Reinbold
he leftmost for clause cannot be evaluated in the > enclosing scope as they may depend on the values obtained from the leftmost > iterable. For example: (x*y for x in range(10) for y in range(x, x+10)). > """ > > So, it's simply because the iterable expression in the

Re: Generator question

2019-03-14 Thread Pierre Reinbold
Le 14/03/19 à 10:45, Peter Otten a écrit : > Pierre Reinbold wrote: > >> Wow, thank you Ian for this very detailed answer, and thank you for taking >> the time for that! Much appreciated! >> >> If I get this right, I have to somehow fix the value of a_list during

Re: Generator question

2019-03-14 Thread Pierre Reinbold
he leftmost for clause cannot be evaluated in the > enclosing scope as they may depend on the values obtained from the leftmost > iterable. For example: (x*y for x in range(10) for y in range(x, x+10)). > """ > > So, it's simply because the iterable expression in the

Generator question

2019-03-13 Thread Pierre Reinbold
Dear all, I want to implement a function computing the Cartesian product if the elements of a list of lists, but using generator expressions. I know that it is already available in itertools but it is for the sake of understanding how things work. I already have a working recursive version, and I

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: >>

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