Last active
December 12, 2015 02:08
-
-
Save abishekk92/4696428 to your computer and use it in GitHub Desktop.
Dynamic type casting
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
def cast(item): | |
try: | |
return int(item) | |
except: | |
pass | |
try: | |
return float(item) | |
except: | |
return item | |
_cast=map(cast,_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment