Help with dict and iter

mattia gervaz at gmail.com
Sun Mar 29 18:41:25 CEST 2009


Il Sun, 29 Mar 2009 12:00:38 -0400, andrew cooke ha scritto:

> mattia wrote:
>>[i wrote]:
>>> don't you just want to have a new job machine?
>>>
>>> for job_list in job_list_list:
>>>   job_machine = dict((x+1, iter(JOBS[x])) for x in range(NJOBS)) for x
>>>   in job_list:
>>>     print(next(job_machine[x]))
> 
> ok - btw you can probably simplify the code.
> 
> this might work:
> 
> job_machine = list(map(iter, JOBS))
> 
> andrew
> 
> [...]
>> Well, you are right, just creating every time a new dict is a good
>> solution, I was just adding complexity to a simple problem, thanks.

Yes, it works perfectly, the only change is next(job_machine[x-1]). 
Thanks.



More information about the Python-list mailing list