के साथ बुलाए गए स्क्रिप्ट के निष्पादन को रोकें क्या किसी अन्य/अन्य कथन का उपयोग किए बिना execfile फ़ंक्शन के साथ बुलाए गए पायथन स्क्रिप्ट को निष्पादित करना संभव है? मैंने exit()
को आजमाया है, लेकिन यह main.py
को समाप्त करने की अनुमति नहीं देता है।execfile
# main.py
print "Main starting"
execfile("script.py")
print "This should print"
# script.py
print "Script starting"
a = False
if a == False:
# Sanity checks. Script should break here
# <insert magic command>
# I'd prefer not to put an "else" here and have to indent the rest of the code
print "this should not print"
# lots of lines below
तुम क्यों प्रयोग कर रहे हैं execfile() और आयात नहीं? – ephemient
मुझे लगता है कि जब मैं एक अलग विंडो में स्क्रिप्ट संपादित कर रहा हूं और उन्हें फ्लाई – JcMaco