Created
August 13, 2018 12:42
-
-
Save LeonardAukea/bfe0ede3b9629958ec7566e3d6b9ed93 to your computer and use it in GitHub Desktop.
Python: parse string as tuple
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 parse_tuple(string): | |
'''Parse a string like '(23.0,11.3)' to tuple of floats.''' | |
try: | |
s = eval(str(string)) | |
if type(s) == tuple: | |
return s | |
return | |
except: | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment