When using a python toolbox (.pyt) in ArcMap, I'll typically follow a pattern where the .pyt file itself is simply a wrapper to collect input arguments and define the tools themselves. Supporting code is kept in separate unit-testable modules.
import supporting_module class MyTool(object): ... def execute(self, parameters, messages): """The source code of the tool.""" some_input = parameters.valueAsText some_output = parameters.valueAsText supporting_module.do_something(some_input, some_output) arcpy.SetParameter(2, some_output)
This works out really well but I've run into one frustrating issue during development. Right-click -> Refresh on the .pyt in ArcMap only refreshes the .pyt file's code. It does not refresh the imported modules, so I have to close and re-open ArcMap whenever I change something there. Fortunately, since I'm testing the code independently, I don't have to do this a ton, but it's still a major hassle. Is there any way around this? Somewhat related - is there any way to fully refresh the Python console (i have a custom site-package that I must also close/reopen ArcMap to pull in changes from as well)?
I'm using ArcMap 10.2.1.