Microsoft
Software
Hardware
Network
Question : global name 'do_traceroute' is not defined?
I got the error message: "NameError: global name 'do_traceroute' is not defined". Can anyone help me find what is wrong with my python code below?
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
import thread
import os
class Connecter:
... ...
def do_traceroute():
os.system('traceroute
www.google.com'
)
... ...
def got_message(self, connection, message):
... ...
print 'Here is a test!'
thread.start_new(do_tracer
oute, ())
... ...
Answer : global name 'do_traceroute' is not defined?
Because
do_traceroute() is a method of your class, you need to say:
1: 2: 3:
def got_message(self, connection, message): ... thread.start_new(self.do_traceroute, ())
Open in New Window
Select All
Random Solutions
Redirection in batch file
SQL Server 2005 Logins Auditing
Exchange 2007 error when sending meeting request to specific user
displaying the count of records in the form
Voltage Sensor [CPU VRM Voltage] detected a failure
File Replication Solution for an Offsite File Server
How to pass multiple openargs
"The operation failed." when sending email using Contact Items in Outlook 2003
Illustrator CS - Error saving .ai file
problem using ioctl , CDROM_DRIVE_STATUS