In Pro (using 2.4.3) when an attribute uses a domain, the Attributes pane provides the ability to display either its stored value or its description (by checking or unchecking 'Show domain and Subtype descriptions').
Is there a way to do this through python directly - i.e. without having to look up the corresponding description in the domain and retrieve the code from there?
So far I have only been able to output the attributes' description using python - not the code.
I've never done it directly (not that this is any marker!).
I'd grab the domain of the cursor fields then use the dictionary provided by the .codedValues attribute for each domain in arcpy.da.ListDomains(). But that may well be what you are saying you're trying to avoid.
Thanks, but yes, that's what I was trying to avoid. However, I have now found that I can do this through the use of cursors as shown below.
for fc in arcpy.ListFeatureClasses('gis.sde.PumpStation', "", 'gis.sde.WaterDistribution'):
with arcpy.da.SearchCursor(fc,('objectid', 'suction_pressure_system')) as cursor: #Suction_pressure_system uses a coded domain
for row in cursor:
print('{}\t{}'.format(row[0],row[1]))
58 AA
43 AA
55 AJ
44 AV
32 AV