I want to do something like the following but im not sure if it is allowed:
try:
import module1
except Exception,e :
if os.path.exists("module2.py"):
print "err importing module1 "+str(e)
else:
pass
I only want to get the print statement if module1 does not exist but there is a file in the current directory named module2.py.
I have tested it where module1 cannot be imported and the file module2.py exists, but I never see the print statement. Can someone advise me what im doing wrong? Is it even possible to have conditional statements within try/except blocks?