printing an element of array (python)
There are two lists/arrays and I want to assig开发者_开发技巧n one by one.
import Mybench
process = []
benchmarks = options.benchmark.split(',')
for bench_name in benchmarks:
process.append(getattr(Mybench, bench_name))
Assume another list (cpus) is also created. Now I want to do this:
i = 0
for i, cpu in cpus:
print "cpu", i, "assigned to ", process[i]
cpu.workload = process[i]
i = i+1
However in the output I see:
cpu 0 assigned to <orphan LiveProcess>
LiveProcess() is returned from Mybench. How can I fis that?
for i, cpu in enumerate(cpus):
print "cpu", i, "assigned to ", process[i]
cpu.workload = process[i]
精彩评论