Is there a way of clearing (flushing) the Python Window in ArcMap from Python (that works in 10.2.1)?
Perfect, didn't realize this option was available. Thank you!!
you seem to have missed del
https://community.esri.com/message/807449-re-method-for-clearing-python-window-in-arcmap-programmatically?commentID=8074…
and if you want to track and otherwise play with the garbage, look at the gc module
<SPAN class="keyword token">import</SPAN> gc dir<SPAN class="punctuation token">(</SPAN>gc<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'DEBUG_COLLECTABLE'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'DEBUG_LEAK'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'DEBUG_SAVEALL'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'DEBUG_STATS'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'DEBUG_UNCOLLECTABLE'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'__doc__'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'__loader__'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'__name__'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'__package__'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'__spec__'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'callbacks'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'collect'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'disable'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'enable'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'garbage'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'get_count'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'get_debug'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'get_objects'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'get_referents'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'get_referrers'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'get_stats'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'get_threshold'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'is_tracked'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'isenabled'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'set_debug'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'set_threshold'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Just del data, garbage collection will shortly reclaim the memory.
The issue is if I write in the python window:
data = []
for row in some_fc:
data.append(row stuff)
I now have this in memory,. Clearing the screen is good, but I can still do :
print data
to get back my stuff, so memory is used. How to release this?
Thanks for taking the time to answer Ted and Dan. I'm really specifically after a way to clear(/reinitialize) the Python Window built-in to ArcMap via Python. It seems like the only way to achieve what I'm after (so far) is via ArcObjects.
Solved for a manual clean up... but no code interface
Since it isn't really a full-fledged python IDE.
From within a python ide, like Spyder or Jupyter QtConsole … cls … clears the screen...
You can save the Transcript if you want to move it to Spyder or one of the Jupter interfaces for further work.
I am a VB man and VB has a clear screen for its shell.....
I have not tried but ran across this:
https://www.geeksforgeeks.org/clear-screen-python/
:::: update did not work in the built in Python interpreter in ArcMap. However it did work external python console/ide
Right now I used for the built in Python interpreter:
print "\n" * 80
del but garbage collection (gc module) is worth a look. When the tool is completed and closed it should free up stuff, at least on the python side
Thanks Joshua, it sounds like it'd be easier to stop abusing the use of the Python Window. I guess that I could probably get at the GPCommandWindow from Python via the comtypes library (http://sourceforge.net/projects/comtypes/).
Thanks Dan, no it was aimed at getting back the memory it consumes, since it seems like it never gets truncated. I output messages to the Python Window for a couple of python addin tools (that are used a lot). The best solution is to stop doing that of course, but just wondered if there's an easy way to clear it.
The short answer, no, or at least nothing that won't involve using a COM client to access ArcObjects. If you are up for that, I would start in the Display (ArcObjects .NET 10.6 SDK) and Framework Library Contents (ArcObjects .NET 10.6 SDK) and look at the GPCommandWindow CoClass.
like printing a bunch of blank lines? which just pushes what you see up off screen. otherwise no, that is an IDE thing
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.