Created
March 31, 2013 16:32
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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