<?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 Re: &amp;lt;type 'exceptions.TypeError'&amp;gt;: 'function' object is unsubscriptable in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/amp-lt-type-exceptions-typeerror-amp-gt-function/m-p/183743#M14131</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Oh, your problem is actually the square brackets in GetParameterAsText:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;env.workspace = arcpy.GetParameterAsText[0] #r"D:\Lorna\Project\Working\Outputs\LooseClip" 
outLocation = arcpy.GetParameterAsText[1] #r"D:\Lorna\Project\Working\Outputs\ClippedFeaturesGDB.gdb" &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;They should be round brackets:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;env.workspace = arcpy.GetParameterAsText(0) #r"D:\Lorna\Project\Working\Outputs\LooseClip" 
outLocation = arcpy.GetParameterAsText(1) #r"D:\Lorna\Project\Working\Outputs\ClippedFeaturesGDB.gdb" &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Square brackets are used for subscripts (indexes to lists, etc.), which is what your error was actually saying...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 09:20:49 GMT</pubDate>
    <dc:creator>StacyRendall1</dc:creator>
    <dc:date>2021-12-11T09:20:49Z</dc:date>
    <item>
      <title>&amp;lt;type 'exceptions.TypeError'&amp;gt;: 'function' object is unsubscriptable</title>
      <link>https://community.esri.com/t5/python-questions/amp-lt-type-exceptions-typeerror-amp-gt-function/m-p/183741#M14129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So, this is my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = arcpy.GetParameterAsText[0] #r"D:\Lorna\Project\Working\Outputs\LooseClip" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outLocation = arcpy.GetParameterAsText[1] #r"D:\Lorna\Project\Working\Outputs\ClippedFeaturesGDB.gdb" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Use the ListFeatureClasses function to return a list of &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# all shapefiles in workspace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fcList = arcpy.ListFeatureClasses()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#shapefiles are named &amp;lt;feature&amp;gt;Clip_&amp;lt;PAid&amp;gt;.shp&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#this loop takes each fc, calculates a field which is populated by the PAid out of its file name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#and then appends the shapefile to the appropriate feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for fc in fcList:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myPA = fc[fc.find("_")+1:fc.find(".")] &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(env.workspace + os.sep + fc, "PAid", "\""+myPA+"\"", "VB", "")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; myFeature = fc[:fc.find("Clip")]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Append_management(fc, outLocation + os.sep + "Clip"+ myFeature)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print myFeature&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The user has to input each parameter as a string. It basically takes the features from a folder, puts an id into a field and appends them together (see comments). This works perfectly on its own, run from pythonwin, but fails miserably when I try to run it from model builder.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;type 'exceptions.TypeError'&amp;gt;: 'function' object is unsubscriptable&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;is the error I get. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know what the problem is? I'm new to this so be nice!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Lorna&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Jul 2011 19:01:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-lt-type-exceptions-typeerror-amp-gt-function/m-p/183741#M14129</guid>
      <dc:creator>LornaJewell</dc:creator>
      <dc:date>2011-07-06T19:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: &lt;type 'exceptions.TypeError'&gt;: 'function' object is unsubscriptable</title>
      <link>https://community.esri.com/t5/python-questions/amp-lt-type-exceptions-typeerror-amp-gt-function/m-p/183742#M14130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Running from within Arc (modelbuilder or as a script tool) does seem to be kind of unstable at times (i.e.: &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/34444-InsertCursor-incredibly-slow-within-Arc"&gt;http://forums.arcgis.com/threads/34444-InsertCursor-incredibly-slow-within-Arc&lt;/A&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First thing you could try is removing your calls to OS, and not importing it - especially as you are just using it to get the system separator - replacing the os.sep with '/' or '\\' should work just fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The next thing you could try is unchecking the "Run Python script in process" box when you are importing the script into Arc, but this often causes other problems...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know how you get on!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Jul 2011 22:48:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-lt-type-exceptions-typeerror-amp-gt-function/m-p/183742#M14130</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2011-07-16T22:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: &lt;type 'exceptions.TypeError'&gt;: 'function' object is unsubscriptable</title>
      <link>https://community.esri.com/t5/python-questions/amp-lt-type-exceptions-typeerror-amp-gt-function/m-p/183743#M14131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Oh, your problem is actually the square brackets in GetParameterAsText:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;env.workspace = arcpy.GetParameterAsText[0] #r"D:\Lorna\Project\Working\Outputs\LooseClip" 
outLocation = arcpy.GetParameterAsText[1] #r"D:\Lorna\Project\Working\Outputs\ClippedFeaturesGDB.gdb" &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;They should be round brackets:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;env.workspace = arcpy.GetParameterAsText(0) #r"D:\Lorna\Project\Working\Outputs\LooseClip" 
outLocation = arcpy.GetParameterAsText(1) #r"D:\Lorna\Project\Working\Outputs\ClippedFeaturesGDB.gdb" &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Square brackets are used for subscripts (indexes to lists, etc.), which is what your error was actually saying...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:20:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-lt-type-exceptions-typeerror-amp-gt-function/m-p/183743#M14131</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-11T09:20:49Z</dc:date>
    </item>
  </channel>
</rss>

