#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.
0:03 Use pdb to inspect GitHub objects.
0:06 Let's say I want to see all the gists of PyBites.
0:14 So we do a get_user on the GitHub object from before.
0:23 And I call get_gists.
0:28 And I look over them.
0:30 Let's copy this in.
0:31 I'm just going to print the description
0:33 created at and the link to the gist.
0:42 So now I knew about these attributes already,
0:46 but if you don't and you want to inspect the gist,
0:48 what you can do is break
0:53 at this point using pdb.
0:57 This would be the same from the REPL
1:00 and this allows me to inspect the objects
1:03 that are currently in the program's execution.
1:05 It's like if the current frame of the execution
1:09 has been paused and you can just inspect all of that.
1:12 It's like, "Time out," and only you are in
1:14 and you can see all the things.
1:16 Nothing is moving.
1:17 I can look at the object.
1:21 This not really, this doesn't look very nice.
1:23 I can use pp.
1:25 And here you see a better representation of the object,
1:30 nicely laid out.
1:32 So here is the section I'm interested in.
1:36 The files, for example, that are associated with this one.
1:40 And look at that how, you can drill down
1:42 how rich the objects are in the API.
1:46 For example, the owner, I can go
1:48 all the way to his avatar, his URL.
1:52 I could inspect the owner,
2:05 etc.
2:06 It's worth to spend a little time
2:08 reading up on pdb.
2:10 It's very useful, not only to debug issues,
2:13 but also to inspect your program and its objects
2:16 as you're building it.
2:17 And we did an article in PyBites about pdb
2:21 which, if you are interested, is an interesting read.
2:28 Back to the example.
2:29 You can also use help from pdb.
2:34 And you have to actually use exclamation mark.
2:38 And look at that.
2:39 Here's the gist class with its methods and attributes.
2:43 So, here, for example, we have a fork of
2:46 and that we can use to see if
2:48 the gist was forked off somebody else's gist.
2:52 So let's try that next.
2:53 I'm going to copy and paste the previous for loop,
2:57 that used that new attribute that we found in help.
3:02 Right, this hangs because I still,
3:04 that's important and maybe less obvious here in
3:08 the Jupyter notebook.
3:09 When I'm still in pdb, I do need to exit the prompt.
3:13 And there you see that it then finishes the cell
3:16 and I'm ready now to execute the next cell.
3:21 So here we see that some of the gists we have
3:24 we're based off forks.
3:27 This one was not.
3:30 And this one, for example, was forked.
3:34 And you can see that here.
3:36 Cool.
3:38 And just because we can.
3:44 And that's a wrap!
3:45 I hope you enjoyed this lesson of the GitHub API.