Reputation: 24715
I have a python script which looks like:
if options.benchmark == 'perlbench':
process = Mybench.perlbench
elif options.benchmark == 'bzip2':
process = Mybench.bzip2
elif options.benchmark == 'gcc':
process = Mybench.gcc
....
np = 1
....
for i in xrange(np):
...
system.cpu[i].workload = process[i]
However I get this error:
system.cpu[i].workload = process[i]
NameError: name 'process' is not defined
Any idea on how to fix that? I am not an expert in python.
Upvotes: 2
Views: 17736
Reputation: 129792
The snippet you've posted appears to be from the cmp.py
script posted here (link currently down).
This script is being run on the command line and requires a valid value to be specified for -b
or --benchmark
. You are either not specifying one or are specifying an invalid one.
The script may be modified by adding an else
case to display a more useful error, but it still won't work unless you use an appropriate value.
For example, you could try this:
python cmp.py --benchmark perlbench
Upvotes: 3
Reputation: 258258
That means that your block
if options.benchmark == 'perlbench':
process = Mybench.perlbench
elif options.benchmark == 'bzip2':
process = Mybench.bzip2
elif options.benchmark == 'gcc':
process = Mybench.gcc
didn't match any of options.benchmark
so the variable process
was never assigned anything. You need to throw an
else:
process = Mybench.<somedefault>
on the end of it (of course filling in <somedefault>
as appropriate). Or if that's an invalid case, you could raise an exception, perhaps.
Upvotes: 3