AnsweredAssumed Answered

Script config issue using arcpy vs. arcgisscripting

Question asked by npssde on Jun 27, 2012
Latest reply on Jun 27, 2012 by npssde
Hello,

I'm updating some Py scripts to use ArcPy (v.10.0, not 10.1) instead of arcgisscripting and I've run into a 'structural' problem. I have a 'master' script/child script set-up I used with arcgisscripting where the master script imports arcpy, gets/checks parameters, then calls the child script. My questions are 1) is this script structure no longer allowed because the arcpy modules must be imported only once (or aliased to prevent conflicts) and 2) Do I have to convert this type of structure to a single script that has explicitly defined (i.e. def()) functions that use one arcpy module definition?

Master *.py script:

import sys, os, arcpy
#do checks...
#Call child script:
Message = child_Script(
    Input_GDB,
    Input_Feature_Class
    )
#Resume master script
print Message


Child *.py script:

def child_Script(
     Input_GDB_Name,
     Input_Feature_Class_Name):

    try:
        import sys, string, os, shutil, time, traceback, arcpy #Have to import arcpy again!!!!       
        import arcpy.sa # Doesn't work... module not found   
    return "Finished!!"
    except:
       ...


Thanks for any ideas!

Lisa

Outcomes