jeudi 4 février 2016

Python try/except depending on variable

i need continue in program after except when variable is True but when variable is False need exit program. I think there will be if else but I'm not sure how to use it.

for examlpe:

var = True

try:
    print 2/0
except:
    exit(1)

... continue executing


var = False

try:
    print 2/0
except:
    exit(1)

... exit 

Thanks for comments.

Aucun commentaire:

Enregistrer un commentaire