<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Python script from ModelBuilder - mysterious bits of code at the beginning and end in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-from-modelbuilder-mysterious-bits-of/m-p/1300460#M70320</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I exported a model from modelbuilder to python and am confused about these bits at the beginning:&amp;nbsp;&lt;/P&gt;&lt;P&gt;from sys import argv&lt;BR /&gt;def FeatureClassGenerator(workspace, wild_card, feature_type, recursive) :&lt;BR /&gt;&amp;nbsp; &amp;nbsp; with arcpy.EnvManager(workspace = workspace):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dataset_list = [""]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if recursive:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; datasets = arcpy.ListDatasets()&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dataset_list.extend(datasets)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for dataset in dataset_list:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; featureclasses = arcpy.ListFeatureClasses(wild_card, feature_type, dataset)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for fc in featureclasses:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; yield os.path.join(workspace, dataset, fc), fc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as well as at the end:&lt;/P&gt;&lt;P&gt;if __name__ == '__main__':&lt;BR /&gt;&amp;nbsp; &amp;nbsp; # Global Environment settings&lt;BR /&gt;&amp;nbsp; &amp;nbsp; with arcpy.EnvManager():&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Model(*argv[1:])&lt;/P&gt;&lt;P&gt;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?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Sat, 17 Jun 2023 00:12:05 GMT</pubDate>
    <dc:creator>IlkaIllers1</dc:creator>
    <dc:date>2023-06-17T00:12:05Z</dc:date>
    <item>
      <title>Python script from ModelBuilder - mysterious bits of code at the beginning and end</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-from-modelbuilder-mysterious-bits-of/m-p/1300460#M70320</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I exported a model from modelbuilder to python and am confused about these bits at the beginning:&amp;nbsp;&lt;/P&gt;&lt;P&gt;from sys import argv&lt;BR /&gt;def FeatureClassGenerator(workspace, wild_card, feature_type, recursive) :&lt;BR /&gt;&amp;nbsp; &amp;nbsp; with arcpy.EnvManager(workspace = workspace):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dataset_list = [""]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if recursive:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; datasets = arcpy.ListDatasets()&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dataset_list.extend(datasets)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for dataset in dataset_list:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; featureclasses = arcpy.ListFeatureClasses(wild_card, feature_type, dataset)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for fc in featureclasses:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; yield os.path.join(workspace, dataset, fc), fc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as well as at the end:&lt;/P&gt;&lt;P&gt;if __name__ == '__main__':&lt;BR /&gt;&amp;nbsp; &amp;nbsp; # Global Environment settings&lt;BR /&gt;&amp;nbsp; &amp;nbsp; with arcpy.EnvManager():&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Model(*argv[1:])&lt;/P&gt;&lt;P&gt;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?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2023 00:12:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-from-modelbuilder-mysterious-bits-of/m-p/1300460#M70320</guid>
      <dc:creator>IlkaIllers1</dc:creator>
      <dc:date>2023-06-17T00:12:05Z</dc:date>
    </item>
  </channel>
</rss>

