Re: Help with dict and iter

2009-04-02 Thread Sion Arrowsmith
mattia ger...@gmail.com wrote: So, I'm looking for a way to reset the next() value every time i complete the scan of a list. itertools.cycle ? -- \S under construction -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with dict and iter

2009-04-02 Thread mattia
Il Thu, 02 Apr 2009 13:44:38 +, Sion Arrowsmith ha scritto: mattia ger...@gmail.com wrote: So, I'm looking for a way to reset the next() value every time i complete the scan of a list. itertools.cycle ? Perfect, thanks. -- http://mail.python.org/mailman/listinfo/python-list

Help with dict and iter

2009-03-29 Thread mattia
Hi all, I a list of jobs and each job has to be processed in a particular order by a list of machines. A simple representation is: # Ordering of machines JOB1 = [3, 1, 2, 4] JOB2 = [2, 3, 1, 4] JOBS = [JOB1, JOB2] NJOBS = len(JOBS) Now, I have a list of jobs and I want to have the associated list

Re: Help with dict and iter

2009-03-29 Thread andrew cooke
mattia wrote: Hi all, I a list of jobs and each job has to be processed in a particular order by a list of machines. A simple representation is: # Ordering of machines JOB1 = [3, 1, 2, 4] JOB2 = [2, 3, 1, 4] JOBS = [JOB1, JOB2] NJOBS = len(JOBS) Now, I have a list of jobs and I want to

Re: Help with dict and iter

2009-03-29 Thread mattia
Il Sun, 29 Mar 2009 11:17:50 -0400, andrew cooke ha scritto: mattia wrote: Hi all, I a list of jobs and each job has to be processed in a particular order by a list of machines. A simple representation is: # Ordering of machines JOB1 = [3, 1, 2, 4] JOB2 = [2, 3, 1, 4] JOBS = [JOB1, JOB2]

Re: Help with dict and iter

2009-03-29 Thread andrew cooke
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:

Re: Help with dict and iter

2009-03-29 Thread mattia
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 -