<?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: unbuffered print() to ArcMap Python window? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/unbuffered-print-to-arcmap-python-window/m-p/171156#M13158</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm getting a similar problem when I run a custom script totally outside of ArcMap (ArcGIS 10.1 SP1 Build 3143). I use '&lt;SPAN style="line-height: 1.5; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; background-color: #ffffff;"&gt; &lt;/SPAN&gt;&lt;SPAN style="line-height: 1.5; margin: 0px; padding: 0px; border: 0px; font-family: 'courier new', courier; vertical-align: baseline; background-color: #ffffff;"&gt;&lt;STRONG style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"&gt;sys.stdout.flush()&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="line-height: 1.5;"&gt;' several times without problem in the code (after running various arcpy gp tools and functions etc.) before the point that crashes without a problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;Upon examination it seems that the standard sys.stdout python class is overwritten during a call to the &lt;/SPAN&gt;arcpy.CalculateField_management gp tool (where I use a Python codeblock to calculate the field values). The new sys.stdout has no flush() method, hence the error. This seems like a pretty fundamental bug to me. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Oct 2015 05:16:13 GMT</pubDate>
    <dc:creator>DarrenSmith</dc:creator>
    <dc:date>2015-10-14T05:16:13Z</dc:date>
    <item>
      <title>unbuffered print() to ArcMap Python window?</title>
      <link>https://community.esri.com/t5/python-questions/unbuffered-print-to-arcmap-python-window/m-p/171155#M13157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a Python Add-In for ArcMap. Add-Ins don't have access to a progress bar (see &lt;A href="https://community.esri.com/thread/93219"&gt;Adding messaging to Python Add-in&lt;/A&gt; ). Plan B - I am writing messages during a lengthy loop to the Python window using &lt;STRONG style="font-family: courier new,courier;"&gt;print(mymsg)&lt;/STRONG&gt;. But nothing appears in the Python window during the loop, then suddenly all the messages appear at the end of the loop. Less than helpful! Sounds like a &lt;A href="http://stackoverflow.com/questions/10019456/usage-of-sys-stdout-flush-method"&gt;buffered &lt;/A&gt;stdout?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I tried doing &lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;sys.stdout.flush()&lt;/STRONG&gt; &lt;/SPAN&gt;after each &lt;STRONG&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;print(),&lt;/SPAN&gt; &lt;/STRONG&gt;and I get this: &lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;AttributeError: 'geoprocessing sys.stdout object' object has no attribute 'flush'.&lt;/STRONG&gt;&lt;/SPAN&gt; I guess that's how the Python window works - ArcMap resets stdout to a custom object that buffers, but lacks a flush() method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whatsa guy to do?&amp;nbsp; Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Aug 2014 15:05:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unbuffered-print-to-arcmap-python-window/m-p/171155#M13157</guid>
      <dc:creator>theMC5</dc:creator>
      <dc:date>2014-08-29T15:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: unbuffered print() to ArcMap Python window?</title>
      <link>https://community.esri.com/t5/python-questions/unbuffered-print-to-arcmap-python-window/m-p/171156#M13158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm getting a similar problem when I run a custom script totally outside of ArcMap (ArcGIS 10.1 SP1 Build 3143). I use '&lt;SPAN style="line-height: 1.5; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; background-color: #ffffff;"&gt; &lt;/SPAN&gt;&lt;SPAN style="line-height: 1.5; margin: 0px; padding: 0px; border: 0px; font-family: 'courier new', courier; vertical-align: baseline; background-color: #ffffff;"&gt;&lt;STRONG style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-family: inherit; vertical-align: baseline;"&gt;sys.stdout.flush()&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="line-height: 1.5;"&gt;' several times without problem in the code (after running various arcpy gp tools and functions etc.) before the point that crashes without a problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;Upon examination it seems that the standard sys.stdout python class is overwritten during a call to the &lt;/SPAN&gt;arcpy.CalculateField_management gp tool (where I use a Python codeblock to calculate the field values). The new sys.stdout has no flush() method, hence the error. This seems like a pretty fundamental bug to me. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Oct 2015 05:16:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unbuffered-print-to-arcmap-python-window/m-p/171156#M13158</guid>
      <dc:creator>DarrenSmith</dc:creator>
      <dc:date>2015-10-14T05:16:13Z</dc:date>
    </item>
  </channel>
</rss>

