Is there a way of clearing (flushing) the Python Window in ArcMap from Python (that works in 10.2.1)?
like printing a bunch of blank lines? which just pushes what you see up off screen. otherwise no, that is an IDE thing
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.
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
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.
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/).
I am a VB man and VB has a clear screen for its shell.....
I have not tried but ran across this:
:::: 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
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.
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.
The issue is if I write in the python window:
data = 
for row in some_fc:
I now have this in memory,. Clearing the screen is good, but I can still do :
to get back my stuff, so memory is used. How to release this?
Just del data, garbage collection will shortly reclaim the memory.
you seem to have missed del
and if you want to track and otherwise play with the garbage, look at the gc module
import gcdir(gc)['DEBUG_COLLECTABLE', 'DEBUG_LEAK', 'DEBUG_SAVEALL', 'DEBUG_STATS', 'DEBUG_UNCOLLECTABLE', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'callbacks', 'collect', 'disable', 'enable', 'garbage', 'get_count', 'get_debug', 'get_objects', 'get_referents', 'get_referrers', 'get_stats', 'get_threshold', 'is_tracked', 'isenabled', 'set_debug', 'set_threshold']
Retrieving data ...