<?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: AddMessage from SearchCursor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209522#M16222</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;AddMessage isn't going to reveal anything unless you are running this inside Pro, use something that covers both inside and standalone scripts.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;tweet&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;msg&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;"""Print a message for both arcpy and python."""&lt;/SPAN&gt;
    m &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"\n{}\n"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;msg&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;m&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;m&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 10:20:04 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2021-12-11T10:20:04Z</dc:date>
    <item>
      <title>AddMessage from SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209515#M16215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working on fine-tuning my collection of Python Scripts and one thing I want to do is to add the AddMessage feature to my script. I have a particular script that produces a series of .PDF Graphs from a SearchCursor function. What I want to be able to do is each time an individual .PDF is created, I want to use the built-in SearchCursor with AddMessage to print a message to the screen showing the name of the .PDF created.&lt;/P&gt;&lt;P&gt;Here is a portion of my script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;list = []&lt;/P&gt;&lt;P&gt;rows = arcpy.SearchCursor(table)&lt;BR /&gt;for row in rows:&lt;BR /&gt; list.append(row.SERVICE_IDENTIFIER) # Double&lt;/P&gt;&lt;P&gt;del row, rows&lt;/P&gt;&lt;P&gt;# Remove duplicates from list&lt;BR /&gt;list = dict.fromkeys(list)&lt;BR /&gt;list = list.keys()&lt;/P&gt;&lt;P&gt;for n in list:&lt;BR /&gt; arcpy.TableSelect_analysis(table, r"in_memory\table_sel", "SERVICE_IDENTIFIER = " + str(n)) # Double&lt;/P&gt;&lt;P&gt;# Get TWACs_Number value&lt;BR /&gt; for row in arcpy.SearchCursor(r"in_memory\table_sel"):&lt;BR /&gt; SERVICE_ADDRESS = row.getValue("SERVICE_ADDRESS") # String&lt;BR /&gt; &lt;BR /&gt; out_graph_name = n&lt;BR /&gt; out_graph_pdf = r"Z:\Operations\Maps and Records\GeoDatabase\MEWCO GIS System\GIS Attachments\Electric System\Electric Usage Demand Graphs\F1 Feeder ALL" + "\\" + str(n)[:-2] + ".pdf"&lt;BR /&gt; input_template = r"Y:\MEWCo GIS System - LOCAL\ELECTRIC SYSTEM\ELECTRIC GRAPHS - CONSTRUCT\GIS Graph Temps\ELECTRIC METER DEMAND - UPDATED 2020.grf"&lt;BR /&gt; input_data = r"in_memory\table_sel"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank You&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2020 17:15:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209515#M16215</guid>
      <dc:creator>ModernElectric</dc:creator>
      <dc:date>2020-06-25T17:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: AddMessage from SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209516#M16216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please use &lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting?sr=search&amp;amp;searchId=aa94a9ad-7958-4b07-bd14-3b3f5be6093d&amp;amp;searchIndex=1"&gt;/blogs/dan_patterson/2016/08/14/script-formatting?sr=search&amp;amp;searchId=aa94a9ad-7958-4b07-bd14-3b3f5be6093d&amp;amp;searchIndex=1&lt;/A&gt;‌, it makes reading code and providing feedback much easier.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2020 18:21:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209516#M16216</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-06-25T18:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: AddMessage from SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209517#M16217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"Y:\MEWCo GIS System - LOCAL\ELECTRIC SYSTEM\ELECTRIC DATASET\MEWCo ELECTRIC SYSTEM\MEWCo ELECTRIC SYSTEM.gdb"&lt;/SPAN&gt;

table &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"ELECTRIC_METER_READING_F1FEEDER_RC30"&lt;/SPAN&gt;

list &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

rows &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;table&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; rows&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    list&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;append&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SERVICE_IDENTIFIER&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# Double&lt;/SPAN&gt;
    
&lt;SPAN class="keyword token"&gt;del&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; rows

&lt;SPAN class="comment token"&gt;# Remove duplicates from list&lt;/SPAN&gt;
list &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; dict&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;fromkeys&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;list&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
list &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; list&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;keys&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; n &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; list&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;TableSelect_analysis&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;table&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"in_memory\table_sel"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SERVICE_IDENTIFIER = "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;n&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# Double&lt;/SPAN&gt;

    &lt;SPAN class="comment token"&gt;# Get TWACs_Number value&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"in_memory\table_sel"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        SERVICE_ADDRESS &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getValue&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"SERVICE_ADDRESS"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# String&lt;/SPAN&gt;
    
    out_graph_name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; n
    out_graph_pdf &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"Z:\Operations\Maps and Records\GeoDatabase\MEWCO GIS System\GIS Attachments\Electric System\Electric Usage Demand Graphs\F1 Feeder ALL"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"\\"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;n&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;".pdf"&lt;/SPAN&gt;
    input_template &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"Y:\MEWCo GIS System - LOCAL\ELECTRIC SYSTEM\ELECTRIC GRAPHS - CONSTRUCT\GIS Graph Temps\ELECTRIC METER DEMAND - UPDATED 2020.grf"&lt;/SPAN&gt;
    input_data &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"in_memory\table_sel"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:19:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209517#M16217</guid>
      <dc:creator>ModernElectric</dc:creator>
      <dc:date>2021-12-11T10:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: AddMessage from SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209518#M16218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;list&lt;/SPAN&gt; isn't a reserved word in Python, it is a built-in class, and people are strongly discouraged from naming variables after built-in objects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In terms of ArcPy, I recommend switching to &lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/data-access/searchcursor-class.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/data-access/searchcursor-class.htm"&gt;SearchCursor—Data Access module | Documentation&lt;/A&gt;.&amp;nbsp; Not only are Data Access cursors more Pythonic, they perform much faster on larger data sets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For finding unique values, instead of creating a list and then using a dict, you can just create a &lt;A class="link-titled" href="https://docs.python.org/3/library/stdtypes.html#set-types-set-frozenset" title="https://docs.python.org/3/library/stdtypes.html#set-types-set-frozenset"&gt;Set - Built-in Types — Python 3.8.3 documentation&lt;/A&gt;&amp;nbsp;from the beginning and populate it within the cursor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where are you having issues with AddMessage, I don't see it anywhere in your code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2020 18:57:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209518#M16218</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-06-25T18:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: AddMessage from SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209519#M16219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joshua:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;I appreciate your feedback. I will take a look at what you recommended. Regarding the AddMessage, its not in the code because I am not really sure how to write/include it. With each .PDF created, I would like a message displayed saying something along the lines of file created and the file name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2020 19:02:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209519#M16219</guid>
      <dc:creator>ModernElectric</dc:creator>
      <dc:date>2020-06-25T19:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: AddMessage from SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209520#M16220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can just stick AddMessage right before the code where you generate the PDF.&amp;nbsp; Speaking of which, where is the code that generates the PDF?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jun 2020 19:10:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209520#M16220</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-06-25T19:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: AddMessage from SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209521#M16221</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I like to create log files that can capture when events take place; typically every geoprocessing step I do is in it's own def and the heavy lifting is in a try/except block: if the process is successful the try block writes a message to the log file saying so; if the process fails the except block logs the error and also sends me an email saying something went wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are just running the script from a console, you don't need to bother with a log file, but I still suggest the try/accept approach and just print() the appropriate message.&amp;nbsp; Here is some sample code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sys&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; smtplib&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; shutil&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; time

&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;sendEmail&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;errMessage&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;   &lt;SPAN class="comment token"&gt;# if errors send email&lt;/SPAN&gt;
    from_addr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"errors@YOUR.org"&lt;/SPAN&gt;
    to_addr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SOMEONE@YOUR.org"&lt;/SPAN&gt;
    subject &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SOMETHING WENT WRONG IN SOME SCRIPT"&lt;/SPAN&gt;
    msg_text &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; errMessage
    msg &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"From: %s\nTo: %s\nSubject: %s\n\n%s"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;%&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;from_addr&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; to_addr&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; subject&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; msg_text&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    server &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; YOUR MAIL SERVER"
    server &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; smtplib&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SMTP&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;server&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    server&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;sendmail&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;from_addr&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; to_addr&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; msg&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    server&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;quit&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;


&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;createLocator&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;locator_style&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; reference_data&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; field_map&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; out_address_locator&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;try&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CreateAddressLocator_geocoding&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;locator_style&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; reference_data&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; field_map&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; out_address_locator&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"ENABLED"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  
        printf&lt;SPAN class="string token"&gt;'Success: Created Locator: {out_address_locator}'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;except&lt;/SPAN&gt; Exception &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; err&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;f&lt;SPAN class="string token"&gt;'Error: could not create locator: {out_address_locator}'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;err&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        sendEmail&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;err&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;main&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;

    logFile r&lt;SPAN class="string token"&gt;"SomeDrive:\path\to\processName.log"&lt;/SPAN&gt;
    logoutput &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; open&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;logFile&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'w'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    beginTime &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; time&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strftime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'%Y-%m-%d %H:%M:%S'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    logoutput&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;write&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;"Began at &lt;SPAN class="comment token"&gt;# " + beginTime + "\n")&lt;/SPAN&gt;
    sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;stdout &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; logoutput

    createLocator&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;locator_style&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; reference_data&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; field_map&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; out_address_locator&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

    logoutput&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;write&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;"Ended at &lt;SPAN class="comment token"&gt;# " + time.strftime('%Y-%m-%d %H:%M:%S') + "\n")&lt;/SPAN&gt;
    logoutput&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;close&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;   &lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the real script, my arguments for createLocator() are spelled out in the main().&amp;nbsp; Also note line 30; this allows me to use print() statements to get info into the log file.&amp;nbsp; The error that is tossed and subsequently caught in the except block gets written to the log and sent in the email...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:20:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209521#M16221</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-11T10:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: AddMessage from SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209522#M16222</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;AddMessage isn't going to reveal anything unless you are running this inside Pro, use something that covers both inside and standalone scripts.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;tweet&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;msg&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;"""Print a message for both arcpy and python."""&lt;/SPAN&gt;
    m &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"\n{}\n"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;msg&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;m&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;m&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:20:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209522#M16222</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-12-11T10:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: AddMessage from SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209523#M16223</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't say when the behavior changed, or even if it ever did, but AddMessage from a stand-alone script or outside of Pro prints the message to the console:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcpy &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; AddMessage
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Hello World"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
Hello World
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Hello World"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
Hello World
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:20:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/addmessage-from-searchcursor/m-p/209523#M16223</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T10:20:07Z</dc:date>
    </item>
  </channel>
</rss>

