Skip to content

Instantly share code, notes, and snippets.

@LeonardAukea
Created August 13, 2018 12:42
Show Gist options
  • Save LeonardAukea/bfe0ede3b9629958ec7566e3d6b9ed93 to your computer and use it in GitHub Desktop.
Save LeonardAukea/bfe0ede3b9629958ec7566e3d6b9ed93 to your computer and use it in GitHub Desktop.
Python: parse string as tuple
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