What does this code mean?
try:
import thread
except ImportError:
del _sys.modules[__name__]#why
raise
But I can’t find thread.py.
why,del _sys.modules[__name__]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That code from Python’s
threading.pyis trying to load the C implementation of thethreadmodule. If it fails (for some reason this hasn’t been compiled, as it would be with all Python distributions) then it deletes itself from the list of modules so thatthreadingdoesn’t show up as having been imported.If you’re looking for the source of the
threadmodule, it’s here: http://svn.python.org/projects/python/trunk/Python/thread.c