I’d like to stop the loading of a module if some modules dependencies arent on machine, how can i do that?
try:
import lxml
except:
print "This module requires lxml"
# WHAT SHOULD I PUT HERE TO STOP MODULE LOADING?
class foo:
pass
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.
Raise the exception, or raise a new one:
If you want to stop the interpreter entirely, use
exit()to terminate the program.