I am running a script that has many Features added. Up until now the script would run and then end and be done but I am adding a WHILE loop that reruns the script.
In this script there are a bunch of Feature Layers that get created like below.
At the end of the Script before it runs again I want to DELETE all of the FeatureLayers that were created in memory... Is there a call that will do the delete.
target_lyr = arcpy.MakeFeatureLayer_management(os.path.join(db['Path'], layer), layer+'_exclude')
Solved! Go to Solution.
So, you want to get rid of interim files that you don't need anymore?
Create an empty list and append the interim files to it as they're created. Then run a FOR loop through the list, deleting each file in the list.
Try this (for each layer):
arcpy.Delete_management(target_lyr)
Yea I was thinking that....but was wondering if at the end of the script I could just DELETE ALL or something like that...like clearing the Cache on your browser