dom426

How can I get the description value of a field that has a domain?

Discussion created by dom426 on Jan 27, 2012
Latest reply on Jan 31, 2012 by csny490
Hello, this is my first time posting on these forums so I apologize if I am doing something wrong beforehand!

I am trying to find a way to get a value from a field that has a domain. I noticed that getting a value using the normal approach only gives me the coded value of the field, but not the description value. Is there any way to retrieve the description? The coded value is not needed for what I am trying to accomplish. Here is the function I am using this in:

def getValues(featureClass,FieldName):
    desc = arcpy.Describe(featureClass)
    cur = arcpy.SearchCursor(featureClass)
    row = cur.next()
    names = []
    while row:
        name = str(row.getValue(FieldName)) #would like to get description and not code value on this line...
        try:
            ind = names.index(name)
        except:
            names.append(name)
        row = cur.next()
        
    return(names)


Thanks!

Outcomes