-1

More of a general/theoretical question:

Often times a Python code for ArcGIS Pro requires the statement "del aprx" at the very end, what does this statement do and is it necessary?

I recently ran a Python snippet changing data sources for a list of feature classes. Absentmindedly, I didn't include "del aprx" at the end, and the snippet ran successfully, but program froze afterward. Could the freeze be related to my omission of "del aprx"?

1
  • 2
    Absolutely, since projects generate locks, and deleting the object removes the locks, but without actual code, it's anyone's guess...
    – Vince
    May 12 at 19:14

1 Answer 1

4

In Python del means delete the object which would release memory and file locks. So if you saw del abc,bob,x this would mean delete the objects abc, bob and x, what ever they are. aprx is the commonly used name for an ArcGIS Pro project object but the coder could have called it anything like banana, but obviously that's a stupid name for the object it represents.

Without seeing the code and the context the object aprx is used no one can comment other than to say the coder was proactively releasing memory by deleting unwanted objects.

1
  • The code utilized the typical: aprx = arcpy.mp.ArcGISProject(r"CURRENT")
    – sparky
    May 12 at 22:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.