00:00 In this video, we’ll take a look at how debugging works in an online coding environment such as Repl.it.
Here we are with the little
for loop code snippet that we wrote before, and as with all the other examples, we want to check up on how does debugging work in here. On the left side, we have a couple of options that are part of this IDE by default, and one of them is the Debugger.
00:23 So we’re going to check that out right now by pressing this. We get a little info popup that tells us, “Okay, click here on the play button here to start debugging.” Got it, thank you.
00:35 And I’ll give it a try, okay? So I press up here. We see we entered the debugger. It’s telling us what line number we’re on. And over here, nothing happened yet.
00:45 I then I can, again, step over, step into—let’s just do this. step into a bit and see what happens. We’re on line 2 now. Nicely highlighted in what’s the line that we’re currently at. And here’s our first printout!
00:59 Now, I can keep stepping through my program like that—the second printout is happening, et cetera. And I can see what line I’m currently on.
01:08 I can do a step over, step into—in this case, it does the same. So I can see that there’s some built-in debugging functionality that can be helpful.
01:16 You don’t have to have your program run all the way through, and maybe you don’t even have to put in lots of print statements, because you can just go step-by-step and see what’s happening.
01:25 Like, this is what’s currently happening in there. However, there’s quite a lot of functionality missing. We don’t really have this nice variable inspector that we had in other examples, et cetera.
01:35 So those are tradeoffs when working with an online environment like this. It obviously isn’t as feature-rich as some of the other options. It’s also probably going to be a bit slower because you’re running it over the internet through your browser instead of natively on your computer. Okay, I’m going to stop this debugger and show you a different way that you can also always debug if you want to interact with your variables, for example.
pdb already with VIM. This is another way you can go. We can just say
import pdb and then set a breakpoint.
And now if I just normally execute my program—just run this. It’s going to stop at this point, where I put the breakpoint in there. And now I’m inside of my program. I can check the current variable,
x refers to
I can step over to the next one, keep going, now I’m at the print statement. It prints out
x—whoops—still refers to
0. I have to step in once more,
and now we’re at
1. So, this is just the default Python household debugger, and you can use it in here as well. If this debugger here doesn’t quite fulfill the needs that you have, just keep in mind that everything that’s part of Python is at your fingertips here as well.
So you do have debugging capabilities also in this online environment, and getting familiar with
pdb is going to be helpful both for your command line as well as for something like this. All right.
03:04 In the next section, we’re going to take a look at a couple of these other options that Repl.it provides for us, which makes it a pretty cool online coding environment.
Become a Member to join the conversation.