Tuesday, 2 February 2016

arcpy - Executing script in Python window of ArcMap?


I've been writing Python in my text editor so I have a Python script, script.py. I'm still developing it so don't want to put it in my toolbox yet, and at the moment this means copying and pasting it from my text editor to the Python window in ArcGIS Desktop.


Is there a command that lets me call it from the ArcGIS Python window?



Something along the lines of:


run script.py

It seems logical that it should exist, but perhaps not.



Answer



You could use execfile.


For instance,


>>> execfile(r'c:\my\script.py')

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...