Hello!
I exported a model from modelbuilder to python and am confused about these bits at the beginning:
from sys import argv
def FeatureClassGenerator(workspace, wild_card, feature_type, recursive) :
with arcpy.EnvManager(workspace = workspace):
dataset_list = [""]
if recursive:
datasets = arcpy.ListDatasets()
dataset_list.extend(datasets)
for dataset in dataset_list:
featureclasses = arcpy.ListFeatureClasses(wild_card, feature_type, dataset)
for fc in featureclasses:
yield os.path.join(workspace, dataset, fc), fc
as well as at the end:
if __name__ == '__main__':
# Global Environment settings
with arcpy.EnvManager():
Model(*argv[1:])
I can remove the one at the beginning without seeing an impact, but if I remove the one at the end, the model doesn't run in the python IDE. I never would have written anything like this had I started from scratch. What is happening here? Do I need this in other scripts too?
Thank you!