AnsweredAssumed Answered

ArcPy: End script if condition is true...

Question asked by mmilner on Sep 15, 2015
Latest reply on Sep 16, 2015 by mmilner

PythonWin; ArcGIS 10.3


I'm trying to implement an exit function that was posted on another site (, but it's not working...


# Create function to exit script

def finish(arg=None):



    except SystemExit:



# Check for nodata (Note: Shapefiles don't support nodata - ArcGIS turns them into zeroes)

if pHx10 == 0:

    print "The point you selected is water or otherwise undefined"



    print "Point's data is defined"


When I input a point that's associated with nodata (i.e. pHx10==0)... the script doesn't exit.


Also... there must be a way to end the else statement without using a print statement. Break and continue are used in while and for statements. So what do you use for an if statement?


I'm new to ArcGIS and don't know Python.