这是我的代码:
from SimPy.Simulation import *
class Message(Process):
def arrive(self, destination):
yield hold, self, 2
try:
print "%s %s going to %s" % (now(), self.name, destination.name)
self.interrupt(destination)
except NameError, x:
print "%s is out of reach" % x
我想要做的是打印出目的地在其名称不存在时无法到达,但我仍然遇到通常的python错误:
Traceback (most recent call last):
File "<pyshell#22>", line 1, in <module>
message.arrive(node2)
NameError: name 'node2' is not defined