Skip to content

Instantly share code, notes, and snippets.

@jackiekazil
Created October 22, 2014 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackiekazil/4181dee7379b4436afe8 to your computer and use it in GitHub Desktop.
Save jackiekazil/4181dee7379b4436afe8 to your computer and use it in GitHub Desktop.
def parse_abbr_from_name(name_abbr):
''' Function to parse the abbreviation from the name '''
try:
name, abbr = name_abbr.strip(')').split('(')
# If there are no '( )', then only one value will return, which
# means that there is no abbreviation, there is only a name.
except ValueError:
name = name_abbr
abbr = None
return name, abbr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment