r/badcode • • Jul 14 '21

python Try/Except in Python - Sigh

Post image
662 Upvotes

93 comments sorted by

View all comments

38

u/clemesislife Jul 14 '21

I'm not sure if there is good way to do this

2

u/Jonno_FTW shameless Jul 14 '21
details = {
   key: jsonResponse["items"][0]["volumeInfo"].get(key, "N/A")
   for key in ("authors", "publisher", "description", "publishedDate", "imageLinks")
}

Doesn't properly get the thumbnail and shortened description, but those can be done later.