I'm writing a python pre-logic script for use in the field calculator. One of my function calls needs to know the feature class name - e.g..
with arcpy.da.SearchCursor("LandUse", "Shape_Area") as cursor:
In this example, the Field Calculator has been launched as a right-click on a column of a attribute table of the LandUse feature class. Rather than hard-wire the feature class name and then have to edit it each time I use the code snippet on a different FC, does arcpy have a method of determining and returning the feature class name for the current context of the field calculator?
I'll just come out and say it, "no" (unfortunately).
You can fairly easily make a script tool, though, in which your feature class or layer would be the only parameter. It's less work to fill in the parameter than to open the attribute table and copy/paste into the field calculator.