#100DaysOfCode in Python Transcripts
Chapter: Days 61-63: Using the Github API with Python
Lecture: Inspecting Github objects with pdb

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Finally, let's wrap up with a pro tip. Use pdb to inspect GitHub objects. Let's say I want to see all the gists of PyBites.
0:15 So we do a get_user on the GitHub object from before. And I call get_gists. And I look over them. Let's copy this in.
0:32 I'm just going to print the description created at and the link to the gist. So now I knew about these attributes already,
0:47 but if you don't and you want to inspect the gist, what you can do is break at this point using pdb. This would be the same from the REPL
1:01 and this allows me to inspect the objects that are currently in the program's execution. It's like if the current frame of the execution
1:10 has been paused and you can just inspect all of that. It's like, "Time out," and only you are in and you can see all the things. Nothing is moving.
1:18 I can look at the object. This not really, this doesn't look very nice. I can use pp. And here you see a better representation of the object,
1:31 nicely laid out. So here is the section I'm interested in. The files, for example, that are associated with this one.
1:41 And look at that how, you can drill down how rich the objects are in the API. For example, the owner, I can go all the way to his avatar, his URL.
1:53 I could inspect the owner, etc. It's worth to spend a little time reading up on pdb.
2:11 It's very useful, not only to debug issues, but also to inspect your program and its objects as you're building it.
2:18 And we did an article in PyBites about pdb which, if you are interested, is an interesting read. Back to the example. You can also use help from pdb.
2:35 And you have to actually use exclamation mark. And look at that. Here's the gist class with its methods and attributes.
2:44 So, here, for example, we have a fork of and that we can use to see if the gist was forked off somebody else's gist. So let's try that next.
2:54 I'm going to copy and paste the previous for loop, that used that new attribute that we found in help. Right, this hangs because I still,
3:05 that's important and maybe less obvious here in the Jupyter notebook. When I'm still in pdb, I do need to exit the prompt.
3:14 And there you see that it then finishes the cell and I'm ready now to execute the next cell. So here we see that some of the gists we have
3:25 we're based off forks. This one was not. And this one, for example, was forked. And you can see that here. Cool. And just because we can.
3:45 And that's a wrap! I hope you enjoyed this lesson of the GitHub API.


Talk Python's Mastodon Michael Kennedy's Mastodon