<?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;quot;Search Cursor() got an unexpected keyword argument 'sort_fields'??? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93022#M7291</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank You Matt for all your help!! You to csny490!! You guys are the best! I really appreciate all your help!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Apr 2013 18:23:29 GMT</pubDate>
    <dc:creator>MichelleCouden1</dc:creator>
    <dc:date>2013-04-24T18:23:29Z</dc:date>
    <item>
      <title>&amp;amp;quot;Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93007#M7276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have this program to go through layers in an mxd and search for missing values. For Example, it sorts through the layer AADT in the FLAG field and then sorts through the layer AADTAnnoLabel in the TFLAG field to compare for missing values. I am getting a sort fields error. Could someone please explain that to me. What am I doing wrong!! I am not finding help online when I search for it. Thanks!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; flayer = "AADT" alayer = "AADTAnnoLabel"&amp;nbsp; FRows = arcpy.SearchCursor(flayer,"", sort_fields="FLAG A") ARows = arcpy.SearchCursor(alayer,"", sort_fields="TFLAG A")&amp;nbsp; FList = [] AList = []&amp;nbsp; for row in FRows: &amp;nbsp;&amp;nbsp;&amp;nbsp; Fvalue = row.getValue("FLAG") &amp;nbsp;&amp;nbsp;&amp;nbsp; FList.append(str(Fvalue))&amp;nbsp; for rows in ARows: &amp;nbsp;&amp;nbsp;&amp;nbsp; Avalue = row.getValue("TFLAG") &amp;nbsp;&amp;nbsp;&amp;nbsp; AList.append(str(Avalue))&amp;nbsp; matched = set(FList) &amp;amp; set(AList)&amp;nbsp; for x in matched: &amp;nbsp;&amp;nbsp;&amp;nbsp; exp = "ID = " + x &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "ADD_TO_SELECTION", exp) &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "SWTCH_SELECTION") &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Apr 2013 13:01:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93007#M7276</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2013-04-22T13:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93008#M7277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not sure if the traditional (non data access) cursors support named parameters (which is what you are doing with the 'sort_fields' named parameter in your code).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think it would either have to be like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="text-decoration:underline;"&gt;In traditional cursors:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FRows = arcpy.SearchCursor(flayer,"", "", "", "FLAG A")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="text-decoration:underline;"&gt;Or in data access cursors like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FRows = arcpy.da.SearchCursor(flayer,["*"], sql_clause=(None, 'ORDER BY FLAG'))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This thread might help: &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/64580-SQL-sort-parameter-syntax-for-da.cursors"&gt;http://forums.arcgis.com/threads/64580-SQL-sort-parameter-syntax-for-da.cursors&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Apr 2013 15:57:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93008#M7277</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2013-04-22T15:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93009#M7278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As of 10.1 all arcpy tools should support kwargs for parameters. 10.0 they did not.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Apr 2013 18:34:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93009#M7278</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-04-22T18:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93010#M7279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Upon testing in v10.1, indeed the 'sort_fields' named parameter/kwarg appears to work as advertised.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Apr 2013 20:47:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93010#M7279</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2013-04-22T20:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93011#M7280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, ran the first code for traditional cursors and got a runtime error of error:999999. Saw that error on the forum but no one answered the poor guy, so I am not sure what that error means. Tried the second code for data access cursors and got the error 'module' object has no attribute 'da'. I'm thinking that means I just need to declare the object maybe??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy

flayer = "AADT"
alayer = "AADTAnnoLabel"

FRows = arcpy.da.SearchCursor(flayer,["*"],sql_clause=(None, 'ORDER BY FLAG'))
ARows = arcpy.da.SearchCursor(alayer,["*"],sql_clause=(None, 'ORDER BY TFLAG'))

FList = []
AList = []

for row in FRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Fvalue = row.getValue("FLAG")
&amp;nbsp;&amp;nbsp;&amp;nbsp; FList.append(str(Fvalue))

for rows in ARows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Avalue = row.getValue("TFLAG")
&amp;nbsp;&amp;nbsp;&amp;nbsp; AList.append(str(Avalue))

matched = set(FList) &amp;amp; set(AList)

for x in matched:
&amp;nbsp;&amp;nbsp;&amp;nbsp; exp = "ID = " + x
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "ADD_TO_SELECTION", exp)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "SWTCH_SELECTION")

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:33:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93011#M7280</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2021-12-10T23:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93012#M7281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It sounds like you are using ArcGIS 10.0 not 10.1.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Apr 2013 14:40:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93012#M7281</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-04-23T14:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93013#M7282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yep, you are correct! I am sorry I did not check. I forgot I work for the state. They don't believe in current. So from the previous threads, I should be using I can use the sort fields I just have it coded wrong correct??? I am sorry this version stuff is hard for me to get.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Apr 2013 15:12:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93013#M7282</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2013-04-23T15:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93014#M7283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Use the "traditional cursor method" shown here: &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/82818-quot-Search-Cursor()-got-an-unexpected-keyword-argument-sort_fields?p=291755&amp;amp;viewfull=1#post291755"&gt;http://forums.arcgis.com/threads/82818-quot-Search-Cursor()-got-an-unexpected-keyword-argument-sort_fields?p=291755&amp;amp;viewfull=1#post291755&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since you are using v10.0, you cannot use the named parameter feature.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Upgrade! v10.2 will be out in June...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Apr 2013 15:33:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93014#M7283</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2013-04-23T15:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93015#M7284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, when I change my code to work for the traditional cursors I get the lovely Error: 999999: Error executing function. Which from what i get from other threads in the forum, this is not good. Iam running it in the python window inside the mxd could that be the problem?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy

flayer = "AADT"
alayer = "AADTAnnoLabel"

FRows = arcpy.SearchCursor(flayer,"","","","FLAG")
ARows = arcpy.SearchCursor(alayer,"","","","TFLAG")

FList = []
AList = []

for row in FRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Fvalue = row.getValue("FLAG")
&amp;nbsp;&amp;nbsp;&amp;nbsp; FList.append(str(Fvalue))

for rows in ARows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Avalue = row.getValue("TFLAG")
&amp;nbsp;&amp;nbsp;&amp;nbsp; AList.append(str(Avalue))

matched = set(FList) &amp;amp; set(AList)

for x in matched:
&amp;nbsp;&amp;nbsp;&amp;nbsp; exp = "ID = " + x
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "ADD_TO_SELECTION", exp)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "SWTCH_SELECTION")
Runtime error &amp;lt;type 'exceptions.RuntimeError'&amp;gt;: ERROR 999999: Error executing function.

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:33:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93015#M7284</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2021-12-10T23:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93016#M7285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think I would rather it start in the PythonWin window instead of the window in ArcMAP. Because I did learn there are other codes for searching. I need help at the start of the code to make that work, because I've only written codes with parameters being set and this one doesn't need it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Apr 2013 19:09:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93016#M7285</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2013-04-23T19:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93017#M7286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;import arcpy&lt;BR /&gt;flayer = "AADT"&lt;BR /&gt;alayer = "AADTAnnoLabel"&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Seems like you need to better define the paths to your inputs. Also, are you sure the fields you are attempting to sort exist in the input tables? Are you sure these are the actual field names and not just aliases?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Apr 2013 19:16:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93017#M7286</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2013-04-23T19:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93018#M7287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;OK, when I change my code to work for the traditional cursors I get the lovely Error: 999999: Error executing function. Which from what i get from other threads in the forum, this is not good. Iam running it in the python window inside the mxd could that be the problem?&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy

flayer = "AADT"
alayer = "AADTAnnoLabel"

FRows = arcpy.SearchCursor(flayer,"","","","FLAG")
ARows = arcpy.SearchCursor(alayer,"","","","TFLAG")

FList = []
AList = []

for row in FRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Fvalue = row.getValue("FLAG")
&amp;nbsp;&amp;nbsp;&amp;nbsp; FList.append(str(Fvalue))

for rows in ARows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Avalue = row.getValue("TFLAG")
&amp;nbsp;&amp;nbsp;&amp;nbsp; AList.append(str(Avalue))

matched = set(FList) &amp;amp; set(AList)

for x in matched:
&amp;nbsp;&amp;nbsp;&amp;nbsp; exp = "ID = " + x
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "ADD_TO_SELECTION", exp)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "SWTCH_SELECTION")
Runtime error &amp;lt;type 'exceptions.RuntimeError'&amp;gt;: ERROR 999999: Error executing function.

&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is the error coming from your search cursor line? If so the most likely cause of a 999999 error is that the fields you are trying to sort by do not exist in that table.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:33:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93018#M7287</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-10T23:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93019#M7288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your good Matt!! Yeah, it's coming from the search cursor line. I did talk to some guys across the hallway and they said just make it a stand alone script in PythonWin because the search cursor commands inside the ArcMAP python window are different. I've only set parameters at the beginning of a code. What would I put at the begnning of this code to make it work as a script tool in ArcMAP without parameters. For Example: He would just open or start the script from the toolbox and it would work that mxd.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Apr 2013 12:15:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93019#M7288</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2013-04-24T12:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93020#M7289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Would I do an mxd = arcpy.mapping.MapDocument..... and then a lstLayers. In order for it to be a stand alone script that I could move into a toolbox.&amp;nbsp; See code below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy

mxd = arcpy.mapping.MapDocument(r"K:\TASS\4_MAPPING_DATA_SUPPORT\Traffic_Mapping\District_Maps\2012\Abilene")
lstLayers = arcpy.mapping.ListLayers(mxd)

flayer = "AADT"
alayer = "AADTAnnoLabel"

FRows = arcpy.SearchCursor(flayer,"","","","FLAG")
ARows = arcpy.SearchCursor(alayer,"","","","TFLAG")

FList = []
AList = []

for row in FRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Fvalue = row.getValue("FLAG")
&amp;nbsp;&amp;nbsp;&amp;nbsp; FList.append(str(Fvalue))

for rows in ARows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Avalue = row.getValue("TFLAG")
&amp;nbsp;&amp;nbsp;&amp;nbsp; AList.append(str(Avalue))

matched = set(FList) &amp;amp; set(AList)

for x in matched:
&amp;nbsp;&amp;nbsp;&amp;nbsp; exp = "ID = " + x
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "ADD_TO_SELECTION", exp)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "SWTCH_SELECTION")
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:33:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93020#M7289</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2021-12-10T23:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93021#M7290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes you can do that. You would just need to reference the layer names as layer objects in the mxd.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;eg&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;flayer = arcpy.mapping.ListLayers(mxd, "AADT")[0]
alayer = arcpy.mapping.ListLayers(mxd, "AADTAnnoLabel")[0]&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:33:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93021#M7290</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-10T23:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93022#M7291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank You Matt for all your help!! You to csny490!! You guys are the best! I really appreciate all your help!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Apr 2013 18:23:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93022#M7291</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2013-04-24T18:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93023#M7292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am getting an exception raised on the SearchCursor. So wouldn't I change the Search Cursor code to, look at the layer and then add a ListFields line of code like what I have below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy

mxd = arcpy.mapping.MapDocument(r"K:\TASS\2 - GEO-DATA PROCESSING SUPPORT\MICHELLE'S WORK_ENTER NOT!!\Work Folder\Python Programming\Wayne's Tools\Abilene_Base_Map.mxd")
lstLayers = arcpy.mapping.ListLayers(mxd)

flayer = arcpy.mapping.ListLayers(mxd, "AADT")[0]
alayer = arcpy.mapping.ListLayers(mxd, "AADTAnnoLabel")[0]

FRows = arcpy.SearchCursor(flayer)
ARows = arcpy.SearchCursor(alayer)

fields = arcpy.ListFields(mxd, "", "FLAG")

FList = []
AList = []
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:33:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93023#M7292</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2021-12-10T23:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: "Search Cursor() got an unexpected keyword argument 'sort_fields'???</title>
      <link>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93024#M7293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am getting an exception raised on my for row lines. I am thinking it is because I have notdeclared the field names correctly. Would I use the ListFields command line or something else. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; mxd = arcpy.mapping.MapDocument(r"K:\TASS\2 - GEO-DATA PROCESSING SUPPORT\MICHELLE'S WORK_ENTER NOT!!\Work Folder\Python Programming\Wayne's Tools\Abilene_Base_Map.mxd") lstLayers = arcpy.mapping.ListLayers(mxd)&amp;nbsp; flayer = arcpy.mapping.ListLayers(mxd, "AADT")[0] alayer = arcpy.mapping.ListLayers(mxd, "AADTAnnoLabel")[0]&amp;nbsp; FRows = arcpy.SearchCursor(flayer) ARows = arcpy.SearchCursor(alayer)&amp;nbsp; #ffields = arcpy.ListFields(mxd, "", "FLAG") #afields = arcpy.ListFields(mxd, "", "TFLAG")&amp;nbsp; FList = [] AList = []&amp;nbsp; for row in FRows: &amp;nbsp;&amp;nbsp;&amp;nbsp; Fvalue = row.getValue("FLAG") &amp;nbsp;&amp;nbsp;&amp;nbsp; FList.append(str(Fvalue))&amp;nbsp; for rows in ARows: &amp;nbsp;&amp;nbsp;&amp;nbsp; Avalue = row.getValue("TFLAG") &amp;nbsp;&amp;nbsp;&amp;nbsp; AList.append(str(Avalue))&amp;nbsp; matched = set(FList) &amp;amp; set(AList)&amp;nbsp; for x in matched: &amp;nbsp;&amp;nbsp;&amp;nbsp; exp = "ID = " + x &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "ADD_TO_SELECTION", exp) &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "SWTCH_SELECTION") &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 14:36:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/amp-amp-quot-search-cursor-got-an-unexpected/m-p/93024#M7293</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2013-04-25T14:36:15Z</dc:date>
    </item>
  </channel>
</rss>

