You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Eric,
I am reading your Python Crash Course and am currently at Chapter 17, Working with APIs.
For the python_repos.py example, I wanted to use the following code: description = repo_dict.get('description', 'No description provided')
Instead of: description = repo_dict['description']
if not description:
description = 'No description provided.'
But this gives me an error code:
"NoneType" object has not attribute 'decode'.
Why is this?
Thank you!
Best,
Tian
The text was updated successfully, but these errors were encountered:
Python grabs the value associated with the key 'description', which is None. This is different than the key not being there. It's a subtle issue, and I'm happy to explain that more carefully if it's not clear.
By the way, here's the code snippet I used to figure out why you were getting that error:
names, plot_dicts= [], []
forrepo_dictinrepo_dicts:
names.append(repo_dict['name'])
# Get the project description, if one is available.# description = repo_dict['description']# if not description:# description = "No description provided."description=repo_dict.get('description', 'blah')
ifnotdescription:
print('dict:', repo_dict)
print('description:', description)
Hi Eric,
I am reading your Python Crash Course and am currently at Chapter 17, Working with APIs.
For the python_repos.py example, I wanted to use the following code:
description = repo_dict.get('description', 'No description provided')
Instead of:
description = repo_dict['description']
if not description:
description = 'No description provided.'
But this gives me an error code:
"NoneType" object has not attribute 'decode'.
Why is this?
Thank you!
Best,
Tian
The text was updated successfully, but these errors were encountered: