开发者

printing an element of array (python)

开发者 https://www.devze.com 2023-04-12 06:00 出处:网络
There are two lists/arrays and I want to assig开发者_开发技巧n one by one. import Mybench process = []

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]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号