title: How to improve repeated use of a try statement in Python?
body: <p>I am trying to extract several elements from a JSON object which contains metadata about a song, using Python. To test if information is available, I am using a try statement for each metadata element. Also, for some string processing that I need to do later in my program, I am saving each value in a different variable. </p>
  
  <p>Any suggestions on how to improve the following code in order to not make a try/except statement for each different metadata value?</p>
  
  <pre><code>if len(r['response']['songs']) is not 0:
      # Request information about the artist
      artist_desc_string = "http://developer.echonest.com/api/v4/artist/terms?api_key="+api_key+\
                           "&amp;name="+artist+"&amp;format=json"
      r2 = requests.get(artist_desc_string).json()
  
      # Extract information from the song JSON
      try:
          title = r['response']['songs'][0]['title']
      except (IndexError, KeyError):
          title = "NULL"
  
      try:
          artist_name = r['response']['songs'][0]['artist_name']
      except (IndexError, KeyError):
          artist_name = "NULL"
  
      try:
          artist_location = r['response']['songs'][0]['artist_location']['location'].replace(',','*')
      except (IndexError, KeyError):
          artist_location = "NULL"
  
      try:
      ...
      ...
  </code></pre>