Target : If the file do not exist , stop run the next script
Code :
import glob ,os , sys
FL = []
for i in FL:
if os.path.isfile(i):
print("file exist")
else:
print("no such a file")
sys.exit("check the errors before run the NEXT script")
print("This is the NEXT script")
Problem : Still return the result as
"This is the NEXT script"
Environment : Python 3.7 , Jupyter
Do i misunderstood the usage of sys.exit() ?
- Since there are over 100 of lines to run if the files EXIST , thus i am avoiding put them all into the if TRUE statement loops. Welcome to point out if this mindset itself also a conceptual mistake programmatically.