Suppose I make a temporary layer from a feature class in a gdb:
select = arcpy.MakeFeatureLayer_management("roads", "select_lyr", "FIPS_CODE = '06023'")
Later I want to see if that layer exists and if it does, delete it.
try: if arcpy.Exists(select): arcpy.Delete_management(select) else: print "select doesn't exist" except: pass
In this scenario, nothing happens. Assuming the layer gets deleted automatically , the
>>> select in the console, I get a
<Result Object>. What am I doing wrong here?! Do I even need to delete this (say I am creating hundreds of similar
selects and I don't want it to run out of memory)? Do I need to add the
arcpy.en.workspace = 'roads' or something before the delete?