Skip to content

Instantly share code, notes, and snippets.

@drwelby
Created March 31, 2013 16:32
Show Gist options
  • Save drwelby/5281185 to your computer and use it in GitHub Desktop.
Save drwelby/5281185 to your computer and use it in GitHub Desktop.
Deal with funky ESRI Python Result objects that don't return sane types, namely getCount which returns not an integer, but a Result object that contains a string.
# Deal with funky python Result objects that don't return sane types
def EZri(result):
value = result.getOutput(0)
#is it numeric?
try:
numval = float(value)
except ValueError:
return value
# maybe it's an int?
if str(int(value)) == value:
return int(value)
else:
return numval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment