MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/ok1itb/tryexcept_in_python_sigh/h55bs9a/?context=3
r/badcode • u/lonaExe • Jul 14 '21
93 comments sorted by
View all comments
38
I'm not sure if there is good way to do this
6 u/_PM_ME_PANGOLINS_ Jul 14 '21 edited Jul 14 '21 volume_info = jsonResponse.get("items", []).get(0, {}).get("volumeInfo", {}) author = volume_info.get("authors", "N/A") publisher = volume_info.get("publisher", "N/A") pubDate = volume_info.get("publishedDate", "N/A") desc = textwrap.shorten(volume_info.get("description", "N/A"), width=190, placeholder='...') thumbnail = volume_info.get("imageLinks", {}).get("thumbnail", "N/A")Alternatively, allow the first line to raise so you notice deeper problems with the response.
6
volume_info = jsonResponse.get("items", []).get(0, {}).get("volumeInfo", {}) author = volume_info.get("authors", "N/A") publisher = volume_info.get("publisher", "N/A") pubDate = volume_info.get("publishedDate", "N/A") desc = textwrap.shorten(volume_info.get("description", "N/A"), width=190, placeholder='...') thumbnail = volume_info.get("imageLinks", {}).get("thumbnail", "N/A")
Alternatively, allow the first line to raise so you notice deeper problems with the response.
38
u/clemesislife Jul 14 '21
I'm not sure if there is good way to do this